
** Install Stata commands
cap: ssc install renames
cap: ssc install ivreg2
cap: ssc install ranktest 
cap: ssc install esttab

clear *
set maxvar 20000
set more off
cap: cd "C:\Users\ricar\Dropbox\Economist\Papers\Information Acquisition\FINAL FILES\Body and Appendix A\"
** Write up here the folder where you unzipped the files

**** GENERATE DATASETS READY FOR ANALYSIS ****
** Prepare State-level Zillow price data
use Data/raw_zillow_median_price_data_by_state, clear
reshape long zillow_median_, i(state) j(time) string
ren zillow_median_ zillow_median
destring zillow_median, replace force
gen year=substr(time,1,4)
destring year, replace force
gen month=substr(time,6,.)
destring month, replace force
drop time
gen time=(year-1996)*12+month

encode state, gen(code_state)
xtset code_state time

forvalues years=1(1)5{
bysort state: egen aux_zillow_mean= mean(zillow_median) if time>=252-(12*`years') & time<=252
bysort state: egen aux_zillow_sd= sd(zillow_median) if time>=252-(12*`years') & time<=252
gen zillow_volatility_`years'y=aux_zillow_sd/aux_zillow_mean
drop aux_zillow_mean aux_zillow_sd
sum zillow_volatility_`years'y if time==252
gen zillow_volatility_`years'y_norm=zillow_volatility_`years'y
gen std_zillow_volatility_`years'y=(zillow_volatility_`years'y-`r(mean)')/`r(sd)'
}
gen zillow_median_2016_12=zillow_median if time==252
gen aux_zillow_median_2016_12=zillow_median if time==252
sum aux_zillow_median_2016_12
gen zillow_median_1000s=zillow_median_2016_12/1000
replace aux_zillow_median_2016_12=(aux_zillow_median_2016_12-`r(mean)')/`r(sd)'
bysort state: egen std_zillow_median=mean(aux_zillow_median_2016_12)
drop aux_zillow_median_2016_12 
keep if time==252
keep state zillow_sizerank std_zillow_volatility_* zillow_median_2016_12 std_zillow_median zillow_median_1000s zillow_volatility_*y_norm
save Data/tomerge_zillow_state, replace

** Load main dataset 
clear *
//set maxvar 15000
use Data/raw_survey_data, clear
cap: drop _merge

*Only need this merge for invite_flag variable
merge m:1 responseid using Data/raw_updates_confidence_from_follow_up, keepusing(invite_flag)
drop if _merge==2
drop _merge

* Merge demographic data
merge m:1 responseid using Data/raw_demographic_information_about_survey_respondents
drop if _merge==2
drop _merge

** Merge certainty measures
drop QA*_mean QA*_sd QA*_uniform
merge 1:1 date responseid using Data/raw_confidence_normal_estimates_nov26
drop if _merge==2
drop _merge

** Merge zillow data
drop state
ren current_state state
merge m:1 state using Data/tomerge_zillow_state, update
drop if _merge==2
drop _merge

renvars QA*, lower
xtset responseid date
foreach var of varlist qa1_1_1 qa1_1_2 qa2_3{
gen follow_up_`var'=F4.`var'
}

gen follow_up_qa2_mean=qa2_mean_revised
gen follow_up_qa2_sd=qa2_sd_revised
gen follow_up_qa2_uniform=qa2_uniform_revised
keep if date==201702

** Define local change
gen local_change_1yf=(q3a_1-q2_1)/q2_1
label var local_change_1yf "Expected Growth rate next 1 year, LOCAL MARKET"

** Define past 1y and 10y
gen value_1yp=qa0_1
label var value_1yp "Expected Value 1 year in past"
gen change_1yp=(193800-qa0_1)/qa0_1
label var change_1yp "Expected Growth rate 1 year in past"

gen value_10yp=qa0_2
label var value_10yp "Expected Value 10 years in past"
gen change_10yp=(193800-qa0_2)/qa0_1
label var change_10yp "Expected Growth rate 10 years in past"

** Define expected house prices
gen prior_value_1yf=qa1_1_2
label var prior_value_1yf "Expected Value 1 year in future (Prior Belief)"

gen prior_change_1yf=(qa1_1_2-193800)/193800
label var prior_change_1yf "Expected Value 1 year in future (Prior Belief)"

gen uncert_prior_change_1yf=qa2_sd/193800
label var uncert_prior_change_1yf "SD of Belief, Expected Value 1 year in future (Prior Belief)"

** Idem above, but for the posterior belief
gen post_value_1yf=qa4_1_2
label var post_value_1yf "Expected Value 1 year in future (Posterior Belief)"

gen post_change_1yf=(qa4_1_2-193800)/193800
label var post_change_1yf "Expected Change 1 year in future (Posterior Belief)"

gen uncert_post_change_1yf=qa5_sd/193800
label var uncert_post_change_1yf "SD of Belief, Expected Value 1 year in future (Posterior Belief)"

** Idem above, but for follow up beliefs
gen follow_up_uncert_change_1yf=follow_up_qa2_sd/193800
label var follow_up_uncert_change_1yf "SD of Belief, Expected Value 1 year in future (Follow-Up)"

gen follow_up_value_1yf=follow_up_qa1_1_2
label var follow_up_value_1yf "Expected Change 1 year in future (Follow Up)"

gen follow_up_change_1yf=(follow_up_qa1_1_2-193800)/193800
label var follow_up_change_1yf "Follow-up Survey, Expected Change 1 year in future (Folluw Up)"


** Check if there are reversals in the BDM
gen consistent_bdm=1
forvalues x1=1(1)10 {
local x2=`x1'+1
replace consistent_bdm=0 if qbetax`x1'>qbetax`x2'
}

*Time variables in minutes
gen qtime_qa3_min=qtime_qa3/60
gen qtime_qa4_min=qtime_qa4/60

save Data/pre_censor.dta, replace 

*=======================Outliers=======================
gen drop_obs=0
drop if prior_change_1yf==.

centile prior_change_1yf, c(2.5 97.5)
local min=`r(c_1)'
local max=`r(c_2)'
replace drop_obs=1 if prior_change_1yf<`min' | prior_change_1yf>`max'

** Censor posterior beliefs to avoid extreme effects of extreme outliers (i.e., typos)
foreach var in post_change_1yf follow_up_change_1yf {
replace `var'=`min' if `var'<`min' & `var'!=.
replace `var'=`max' if `var'>`max' & `var'!=.
}
drop if drop_obs==1

**Winsorize time to answer beliefs
centile qtime_qa3_min, c(1.5 98.5)
replace qtime_qa3_min=`r(c_1)' if qtime_qa3_min<`r(c_1)' & !missing(qtime_qa3_min)
replace qtime_qa3_min=`r(c_2)' if qtime_qa3_min>`r(c_2)' & !missing(qtime_qa3_min)

centile qtime_qa4_min, c(1.5 98.5)
replace qtime_qa4_min=`r(c_1)' if qtime_qa4_min<`r(c_1)' & !missing(qtime_qa4_min)
replace qtime_qa4_min=`r(c_2)' if qtime_qa4_min>`r(c_2)' & !missing(qtime_qa4_min)

*Winsorize large uncertainty 
centile uncert_prior_change_1yf, c(1.5 98.5)
local min=`r(c_1)'
local max=`r(c_2)'

* Windzorise uncertainty outcomes
foreach var in uncert_prior_change_1yf uncert_post_change_1yf follow_up_uncert_change_1yf {
replace `var'=`max'  if `var'>`max' & `var'!=.
}

*=======================================================

**Log time variables
gen log_qtime_qa4=log(qtime_qa4_min)
gen log_qtime_qa3=log(qtime_qa3_min)

** Generate MWP variable indiv
gen double bdm_cutoff=0
replace bdm_cutoff=0.01 if qbetax1==1
replace bdm_cutoff=0.50 if qbetax2==1
replace bdm_cutoff=1 if qbetax3==1
replace bdm_cutoff=1.50 if qbetax4==1
replace bdm_cutoff=2 if qbetax5==1
replace bdm_cutoff=2.50 if qbetax6==1
replace bdm_cutoff=3 if qbetax7==1
replace bdm_cutoff=3.50 if qbetax8==1
replace bdm_cutoff=4 if qbetax9==1
replace bdm_cutoff=4.50 if qbetax10==1
replace bdm_cutoff=5 if qbetax11==1
replace bdm_cutoff=. if consistent_bdm==0 | qa3_4==1
replace bdm_cutoff=0 if qa3_4==1 //zero if no info requested

** Construct variable for interval regression
gen bdm_int1=.
gen bdm_int2=.
replace bdm_int1=. if bdm_cutoff==0
replace bdm_int2=0.01 if bdm_cutoff==0
replace bdm_int1=0.01 if abs(bdm_cutoff-0.01)<0.001
replace bdm_int2=0.50 if abs(bdm_cutoff-0.01)<0.001
replace bdm_int1=0.50 if bdm_cutoff==0.50
replace bdm_int2=1 if bdm_cutoff==0.50
replace bdm_int1=1 if bdm_cutoff==1
replace bdm_int2=1.50 if bdm_cutoff==1
replace bdm_int1=1.5 if bdm_cutoff==1.5
replace bdm_int2=2 if bdm_cutoff==1.5
replace bdm_int1=2 if bdm_cutoff==2
replace bdm_int2=2.50 if bdm_cutoff==2
replace bdm_int1=2.50 if bdm_cutoff==2.5
replace bdm_int2=3 if bdm_cutoff==2.5
replace bdm_int1=3 if bdm_cutoff==3
replace bdm_int2=3.50 if bdm_cutoff==3
replace bdm_int1=3.50 if bdm_cutoff==3.5
replace bdm_int2=4 if bdm_cutoff==3.5
replace bdm_int1=4 if bdm_cutoff==4
replace bdm_int2=4.50 if bdm_cutoff==4
replace bdm_int1=4.5 if bdm_cutoff==4.5
replace bdm_int2=5 if bdm_cutoff==4.5
replace bdm_int1=5 if bdm_cutoff==5
replace bdm_int2=. if bdm_cutoff==5
replace bdm_int1=. if consistent_bdm==0 | qa3_4==1
replace bdm_int2=. if consistent_bdm==0 | qa3_4==1

*Impute WTP with 0 if don't want info
replace bdm_int1=. if qa3_4==1
replace bdm_int2=0 if qa3_4==1

** Variable for nice-looking histograms of MWP
gen hist_bdm=bdm_cutoff+0.25
replace hist_bdm=-.25 if hist_bdm==0.25
replace hist_bdm=.25 if abs(hist_bdm-.26)<0.001

** Reward Treatment indicator
gen high_reward=qa3v==1
gen reward_size=(1+9*high_reward)

** Favorite information chosen
gen info_chosen=.
replace info_chosen=1 if qa3_3==1
replace info_chosen=2 if qa3_1==1
replace info_chosen=3 if qa3_2==1
replace info_chosen=4 if qa3_4==1
label define info_chosen 1 "forecast" 2 "last 1y change" 3 "last 10y change" 4 "none"
label values info_chosen info_chosen
gen forecast_chosen_over_past=info_chosen==1 if info_chosen!=4

** Variables about likelihood to buy a new house
gen aux_q6d_1=q6d_1/100
replace aux_q6d_1=0 if q6a_1==0
gen aux_q6c_1=q6c_1
replace aux_q6c_1=0 if q6a_1==0
gen chance_buy=(q6a_1/100)*(aux_q6c_1/100)+(1-(q6a_1/100)*(aux_q6c_1/100))*(q7a_1/100)

** Owner dummy
gen owner=(own_rent!=2) if own_rent!=.

** A measure of biased priors (with respect to the forecasters)
gen prior_bias=abs(prior_value_1yf-(193800*1.036))/(193800*1.036)

** Information-provision part
gen dummy_shown=1
local N=_N
forvalues i=1(1)`N' { 
qui {
local x=wrow[`i']
if `x'!=. {
noi: display `x'
noi: tab qbetax`x'
noi: replace dummy_shown=0 if qbetax`x'==2 & _n==`i'
}
}
}
replace dummy_shown=. if wrow==.
replace dummy_shown=0 if info_chosen==4
label var dummy_shown "=1 if Information Shown"

* Key variables for the learning estimates
gen gap_value_shown=0 if dummy_shown!=.
replace gap_value_shown=193800*1.036-prior_value_1yf if info_chosen==1 & dummy_shown==1
replace gap_value_shown=193800*1.068-prior_value_1yf if info_chosen==2 & dummy_shown==1
replace gap_value_shown=193800*0.999-prior_value_1yf if info_chosen==3 & dummy_shown==1
replace gap_value_shown=0 if info_chosen==4 
gen gap_change_shown=0 if dummy_shown!=.
replace gap_change_shown=0.036-prior_change_1yf if info_chosen==1 & dummy_shown==1
replace gap_change_shown=0.068-prior_change_1yf if info_chosen==2 & dummy_shown==1
replace gap_change_shown=-0.001-prior_change_1yf if info_chosen==3 & dummy_shown==1
replace gap_change_shown=0 if info_chosen==4
gen gap_change_potential=.
replace gap_change_potential=0.036-prior_change_1yf if info_chosen==1 & dummy_shown!=.
replace gap_change_potential=0.068-prior_change_1yf if info_chosen==2 & dummy_shown!=.
replace gap_change_potential=-0.001-prior_change_1yf if info_chosen==3 & dummy_shown!=.
replace gap_change_potential=10 if info_chosen==4 //large number should be accounted for with a fixed effect for no info in analysis
gen revision_value_1yf=post_value_1yf-prior_value_1yf
gen revision_change_1yf=post_change_1yf-prior_change_1yf
gen f_up_revision_value_1yf=follow_up_value_1yf-prior_change_1yf
gen f_up_revision_change_1yf=follow_up_change_1yf-prior_change_1yf

** Generate winsorized versions of the variables
winsor revision_change_1yf, gen(w_revision_change_1yf) p(0.025)
winsor f_up_revision_change_1yf, gen(w_f_up_revision_change_1yf)  p(0.025)

* Generate censorized version for the graphs
foreach var of varlist prior_change* post_change* follow_up_change* {
gen cens_`var'=`var'
replace cens_`var'=-0.01 if `var'<-0.01 & `var'!=.
replace cens_`var'=0.08 if `var'>0.08 & `var'!=.
}

** Auxiliary dummies about the maximum willingess to pay for information
egen dummies_bdm_cutoff=group(bdm_cutoff)

** Prepare control variables
cap: drop white
gen white=(race==1) if !missing(race)
replace gender=. if gender==9

** People who looked for info in the past bid more for the info
gen looked_for_info=q12>1 if q12!=.

**Owns a residency (=1)
gen own_residency=q4==1

**Income variable
gen income=.
replace income=5000 if hh_income==1
replace income=15000 if hh_income==2
replace income=25000 if hh_income==3
replace income=35000 if hh_income==4
replace income=45000 if hh_income==5
replace income=55000 if hh_income==6
replace income=67500 if hh_income==7
replace income=87500 if hh_income==8
replace income=125000 if hh_income==9
replace income=175000 if hh_income==10
replace income=250000 if hh_income==11
gen ln_income=log(income)

**Wrow variable 
gen wrow_cat3=.
replace wrow_cat3=1 if wrow==1 | wrow==2 |wrow==3 | wrow==4
replace wrow_cat3=2 if wrow==5 | wrow==6 | wrow==7 | wrow==8
replace wrow_cat3=3 if wrow==9 | wrow==10 | wrow==11

**Binary Variables
gen numeracy_bi=.
replace numeracy_bi=0 if total_numeracy<=4
replace numeracy_bi=1 if total_numeracy>4
gen education_bi=(education>4) if education!=.
gen age_bi = (age>50) if age!=.
gen own_bi=own_rent
replace own_bi = . if own_bi==3
recode own_bi (2=0)
gen info_chosen_bi_total=.
replace info_chosen_bi_total=1 if info_chosen==1
replace info_chosen_bi_total=2 if info_chosen!=1
gen info_chosen_bi_1yr=.
replace info_chosen_bi_1yr=1 if info_chosen==1
replace info_chosen_bi_1yr=2 if info_chosen==2
gen info_chosen_bi_10yr=.
replace info_chosen_bi_10yr=1 if info_chosen==1
replace info_chosen_bi_10yr=2 if info_chosen==3
gen prior_bias_bi=.
replace prior_bias_bi=1 if prior_bias<=0.0287722
replace prior_bias_bi=2 if prior_bias>0.0287722
gen chance_buy_bi=.
replace chance_buy_bi=1 if chance_buy<=.1891
replace chance_buy_bi=2 if chance_buy>.1891
gen prior_value_1yf_1000=prior_value_1yf/1000 //House Price expected in 1000$
gen above_median_age=(age>50) if age!=.

gen forecast_chosen=info_chosen==1 
gen y1_chosen=info_chosen==2 
gen y10_chosen=info_chosen==3 
gen none_chosen=info_chosen==4


* Other useful variables
gen foll_resp=0
replace foll_resp=1 if invite_flag==1 & follow_up_change_1yf!=.	
gen foll_resp2=.
replace foll_resp2=0 if invite_flag==1
replace foll_resp2=1 if invite_flag==1 & follow_up_change_1yf!=.
gen coll_grad=0 if !missing(education)
replace coll_grad=1 if education>4 & !missing(education)
gen HH_income=0 if !missing(income)
replace HH_income=1 if income>60000 & !missing(income)
label define high_reward 0 "Low_Reward" 1 "High_Reward", replace
label values high_reward high_reward

* Gender
gen female=0 if !missing(gender)
replace female=1 if gender==1

* Probability move, prob move and buy home 
gen prob_move = q6a_1/100
label var prob_move "Probably move in 3 years"
replace q6c_1=0 if q6a_1<5 // if <5% prob of move, not asked about prob buy if move
gen prob_move_and_buy = q6a_1*q6c_1/(100*100)
label var prob_move_and_buy "Probably move in 3 years and buy house"

* Looked for outside infor during Survey 
gen info_looked_during=0
replace info_looked_during=1 if qend==1

* Informedness about Home Prices
gen inform1=-abs((qa0_1-181500))
gen inform10=-abs((qa0_2-195600))
foreach var of varlist inform1 inform10{
	quietly sum `var'
	replace `var'=(`var'-r(mean))/r(sd)
}

save Data/data_ready_for_analysis, replace


*******************************************
*******************************************
************START DATA ANALYSIS************
*******************************************
*******************************************

*************************
*** FIGURES IN BODY *****
*************************

**************************************************************************
*** Figure 1: Type of Information Most Preferred
use Data/data_ready_for_analysis, clear  
* Panel a (Information Preferred)* 
tab info_chosen 
local obs=string(`r(N)', "%9.0g")
two (hist info_chosen, lstyle(none) width(0.8) xlabel(1.4 "forecast" 2.2 "last 1y change" 3 "last 10y change" 3.8 "none", angle(45)) yti("Percent", height(5) ) xti("Type of information Most Preferred", height (5)) scheme(s1mono) percent xtitle("Type of Information Most Preferred")) 
graph export "output/Info_Preferred.eps", replace 
graph export "output/Info_Preferred.pdf", replace 
* Panel b (Info Preffered on Numeracy)*
count if total_numeracy<=4
local obs1=string(`r(N)', "%9.0g")
count if total_numeracy>4
local obs2=string(`r(N)', "%9.0g")
mlogit info_chosen numeracy_bi, robust
test [last_1y_change]numeracy_bi=[last_10y_change]numeracy_bi=[none]numeracy_bi=0
local kk=int(r(p)*100)
	if `kk'<10{
		if `kk'==0{
		global ks="<0.01"
		}
		else{
		global ks="0.0`kk'"
		}
	}
	else	{
		global ks="0.`kk'"
	}
two (hist info_chosen if total_numeracy<=4, lstyle(none)  width(0.8) xlabel( 1.4 "forecast" 2.2 "last 1y change" 3 "last 10y change" 3.8 "none", angle(45)) yti("Percent", height(5) ) xti("Type of information Most Preferred", height (5)) ylabel(0(10)55) scheme(s1mono) percent xtitle("Type of Information Most Preferred")) (hist info_chosen if total_numeracy>4, fcolor(none) lcolor(black) lwidth(medthick) width(0.8) xlabel( 1.4 "forecast" 2.2 "last 1y change" 3 "last 10y change" 3.8 "none" , angle(45)) percent xtitle("Type of Information Most Preferred") legend(label(1 "Below-median Numeracy (N=`obs1')") label(2 "Above-median Numeracy (N=`obs2')") region(color(none)) cols(1) position(1) ring(0) size(medsmall)) note("P-value of difference: $ks", justification(left) position(11) ring(0)))
graph export "output/Info_chosen_numeracy.eps", replace 
graph export "output/Info_chosen_numeracy.pdf", replace 
*Panel c (Info Preferred according Education)* 
count if education<=4
local obs1=string(`r(N)', "%9.0g")
count if education>4
local obs2=string(`r(N)', "%9.0g")
mlogit info_chosen education_bi, robust 
test [last_1y_change]education_bi=[last_10y_change]education_bi=[none]education_bi=0
local kk=int(r(p)*100)
	if `kk'<10{
		if `kk'==0{
		global ks="<0.01"
		}
		else{
		global ks="0.0`kk'"
		}
	}
	else	{
		global ks="0.`kk'"
	}
two (hist info_chosen if education<=4, lstyle(none)  width(0.8) xlabel( 1.4 "forecast" 2.2 "last 1y change" 3 "last 10y change" 3.8 "none", angle(45)) yti("Percent", height(5) ) xti("Type of information Most Preferred", height (5)) ylabel(0(10)55) scheme(s1mono) percent xtitle("Type of Information Most Preferred")) (hist info_chosen if education>4, fcolor(none) lcolor(black) lwidth(medthick) width(0.8) xlabel(1.4 "forecast" 2.2 "last 1y change" 3 "last 10y change" 3.8 "none", angle(45)) percent xtitle("Type of Information Most Preferred") legend(label(1 "Not College Graduate (N=`obs1')") label(2 "College Graduate (N=`obs2')") region(color(none)) cols(1) position(1) ring(0)) note("P-value of difference: $ks", justification(left) position(11) ring(0)))
graph export "output/Info_chosen_educ.eps", replace 
graph export "output/Info_chosen_educ.pdf", replace 
***
*************************************************************************



**************************************************************************
*** Figure 2: Willingness to Pay for Favorite Information
use Data/data_ready_for_analysis, clear 
*Panel a (Histogram of Distribution of MWP)*
sum hist_bdm
local obs=string(`r(N)', "%9.0g")
hist hist_bdm, lstyle(none) start(-0.5) width(0.5) xlabel(-0.25 "<=$0.01" 0.25 "$0.01-0.5" 0.75 "$0.5-1.0 " 1.25 "$1.0-1.5 " 1.75 "$1.5-2.0" 2.25 "$2.0-2.5" 2.75 "$2.5-3.0" 3.25 "$3.0-3.5" 3.75 "$3.5-4.0" 4.25 "$4.0-4.5" 4.75 "$4.5-5.0" 5.25 ">=$5.0", angle(45)) scheme(s1mono) percent yti("Percent", height(5) ) xti("Willingness to Pay for Information", height (5)) ylabel(0(10)50) yscale(range(-1.5(1)50)) note("N=`obs'", justification(left) position(2) ring(0))
graph export "output/MWP.eps", replace 
graph export "output/MWP.pdf", replace 
*Panel b (MWP by Reward Size)*
count if high_reward==0 & hist_bdm!=.
local obs1=string(`r(N)', "%9.0g")
count if high_reward==1 & hist_bdm!=.
local obs2=string(`r(N)', "%9.0g")
*escftest hist_bdm, group(high_reward)
*local kk=int(r(p_val)*100)
ranksum hist_bdm, by(high_reward)
local kk=int(2 * normprob(-abs(r(z))) * 100)
	if `kk'<10{
		if `kk'==0{
		global ks="<0.01"
		}
		else{
		global ks="0.0`kk'"
		}
	}
	else	{
		global ks="0.`kk'"
	}
two (hist hist_bdm if high_reward==0, lstyle(none)  start(-0.5) width(0.5) xlabel(-0.25 "<=$0.01" 0.25 "$0.01-0.5" 0.75 "$0.5-1.0 " 1.25 "$1.0-1.5 " 1.75 "$1.5-2.0" 2.25 "$2.0-2.5" 2.75 "$2.5-3.0" 3.25 "$3.0-3.5" 3.75 "$3.5-4.0" 4.25 "$4.0-4.5" 4.75 "$4.5-5.0" 5.25 ">=$5.0", angle(45)) scheme(s1mono) percent yti("Percent", height(5) ) xti("Willingness to Pay for Information", height (5)) ylabel(0(10)50)) (hist hist_bdm if high_reward==1, fcolor(none) lcolor(black) lwidth(medthick)  start(-0.5) width(0.5) xlabel(-0.25 "<=$0.01" 0.25 "$0.01-0.5" 0.75 "$0.5-1.0 " 1.25 "$1.0-1.5 " 1.75 "$1.5-2.0" 2.25 "$2.0-2.5" 2.75 "$2.5-3.0" 3.25 "$3.0-3.5" 3.75 "$3.5-4.0" 4.25 "$4.0-4.5" 4.75 "$4.5-5.0" 5.25 ">=$5.0", angle(45)) percent yti("Percent", height(5) ) xti("Willingness to Pay for Information", height (5)) ylabel(0(10)50) legend(label(1 "10$ Reward (N=`obs1')") label(2 "100$ Reward (N=`obs2')") region(color(none)) cols(1) position(11) ring(0) size(medsmall)) note("P-value of difference: $ks", justification(left) position(2) ring(0)))
graph export "output/MWP_highbid.eps", replace 
graph export "output/MWP_highbid.pdf", replace 
***
*************************************************************************


**************************************************************************
*** Figure 3: Learning Rates from Information
use Data/data_ready_for_analysis, clear  
*Panel a (All)*
reg w_revision_change_1yf gap_change_shown i.dummies_bdm_cutoff gap_change_potential  prior_change_1yf none_chosen if consistent_bdm==1, robust // consistent_bdm==1 not required here, dummies_bdm_cutoff missing if inconsistent bdm
local b=string(_b[gap_change_shown], "%9.3f")
local s=string(_se[gap_change_shown], "%9.3f")
local r2=string(e(r2), "%9.3f")
local n=string(e(N), "%9.0fc")
binscatter w_revision_change_1yf gap_change_shown if consistent_bdm==1, color(black) name(test, replace) controls(i.dummies_bdm_cutoff gap_change_potential  prior_change_1yf none_chosen) scheme(s1mono) ytitle("Posterior Belief - Prior Belief", height (5)) xtitle("Information Value - Prior Belief", height (5)) note("          Slope=  `b' (`s')" "          R{superscript:2} =  `r2'" "          N =  `n'", justification(left) position(4) ring(0) size(medsmall)  )  xlabel(-.03 "-3%" -0.02 "-2%" -0.01 "-1%" 0 "0%" 0.01 "1%" 0.02 "2%" 0.03 "3%" 0.04 "4%" 0.05 "5%")  ylabel( -0.005 "-0.5%" 0 "0.0%" 0.005 "0.5%" 0.01 "1.0%" 0.015 "1.5%" 0.02 "2.0%"  0.025 "2.5%") yscale(range(-0.005(0.0005)0.025))
graph export "output/learningrate_shortterm.eps", replace
graph export "output/learningrate_shortterm.pdf", replace
*Panel b (By Info Chosen)*
reg w_revision_change_1yf gap_change_shown i.dummies_bdm_cutoff  prior_change_1yf gap_change_potential if consistent_bdm==1 &  info_chosen==1, robust
local b1=string(_b[gap_change_shown], "%9.3f")
local s1=string(_se[gap_change_shown], "%9.3f")
local n1=string(e(N), "%9.0fc")
reg w_revision_change_1yf gap_change_shown i.dummies_bdm_cutoff  prior_change_1yf gap_change_potential if consistent_bdm==1 &  info_chosen==2, robust
local b2=string(_b[gap_change_shown], "%9.3f")
local s2=string(_se[gap_change_shown], "%9.3f")
local n2=string(e(N), "%9.0fc")
reg w_revision_change_1yf gap_change_shown i.dummies_bdm_cutoff  prior_change_1yf gap_change_potential if consistent_bdm==1 &  info_chosen==3, robust
local b3=string(_b[gap_change_shown], "%9.3f")
local s3=string(_se[gap_change_shown], "%9.3f")
local n3=string(e(N), "%9.0fc")
reg w_revision_change_1yf gap_change_shown i.dummies_bdm_cutoff   prior_change_1yf gap_change_potential if consistent_bdm==1 &  info_chosen==1
est store est1
reg w_revision_change_1yf gap_change_shown i.dummies_bdm_cutoff  prior_change_1yf gap_change_potential if consistent_bdm==1 &  info_chosen==2
est store est2
reg w_revision_change_1yf gap_change_shown i.dummies_bdm_cutoff  prior_change_1yf gap_change_potential if consistent_bdm==1 &  info_chosen==3
est store est3
quietly suest est1 est2 est3, vce(robust)
test [est1_mean]gap_change_shown = [est2_mean]gap_change_shown = [est3_mean]gap_change_shown
local p: display %4.3f `r(p)'
est clear
binscatter w_revision_change_1yf gap_change_shown if consistent_bdm==1 & info_chosen!=4, color(gs2 gs7 gs12) controls(i.dummies_bdm_cutoff prior_change_1yf gap_change_potential) by(info_chosen) scheme(s1mono)   ytitle("Posterior Belief - Prior Belief", height (5)) xtitle("Information Value - Prior Belief", height (5)) note("          Slope{subscript:Forecast} =  `b1' (`s1')" "          Slope{subscript:1-year} =  `b2' (`s2')" "          Slope{subscript:10-years} =  `b3' (`s3')" "          P-value =  `p'", justification(left) position(4) ring(0) size(medsmall)  )  legend(label(1 "Forecast (N=`n1')") label(2 "Last 1 year change (N=`n2')") label(3 "Last 10 year change (N=`n3')") region(color(none)) cols(1) position(11) ring(0) size(medsmall))  xlabel( -.03 "-3%"  -0.02 "-2%" -0.01 "-1%"  0 "0%" 0.01 "1%" 0.02 "2%"  0.03 "3%" 0.04 "4%" 0.05 "5%" )  ylabel( -0.02 "-2%" -0.01 "-1%" 0 "0%"  0.01 "1%" 0.02 "2%" 0.03 "3%"  0.04 "4%" 0.05 "5%") yscale(range(-0.02(0.005)0.035))
graph export "output/learningrate_byinfo.eps", replace
graph export "output/learningrate_byinfo.pdf", replace
*Panel c (By WTP)*
tabstat bdm_cutoff, statistics( mean median )  //median prior_bias  4.5
gen bdm_cutoff_bi=.
replace bdm_cutoff_bi=1 if  bdm_cutoff<2.5
replace bdm_cutoff_bi=2 if  bdm_cutoff>=2.5
reg w_revision_change_1yf gap_change_shown i.dummies_bdm_cutoff  prior_change_1yf gap_change_potential none_chosen if consistent_bdm==1 & bdm_cutoff_bi==1,  robust  //Below
local b_b=string(_b[gap_change_shown], "%9.3f")
local s_b=string(_se[gap_change_shown], "%9.3f")
local n_b=string(e(N), "%9.0fc")
reg w_revision_change_1yf gap_change_shown i.dummies_bdm_cutoff  prior_change_1yf gap_change_potential none_chosen if consistent_bdm==1 & bdm_cutoff_bi==2, robust //Above
local b_a=string(_b[gap_change_shown], "%9.3f")
local s_a=string(_se[gap_change_shown], "%9.3f")
local n_a=string(e(N), "%9.0fc")
reg w_revision_change_1yf gap_change_shown b3.dummies_bdm_cutoff  prior_change_1yf gap_change_potential none_chosen if consistent_bdm==1 & bdm_cutoff_bi==1  //Below
est store est1
reg w_revision_change_1yf gap_change_shown b3.dummies_bdm_cutoff  prior_change_1yf gap_change_potential none_chosen if consistent_bdm==1 & bdm_cutoff_bi==2 //Above
est store est2
quietly suest est1 est2, vce(robust)
test [est1_mean]gap_change_shown = [est2_mean]gap_change_shown
local p: display %4.3f `r(p)'
est clear
binscatter w_revision_change_1yf gap_change_shown if consistent_bdm==1, color(gs2 gs7)  controls(i.dummies_bdm_cutoff gap_change_potential prior_change_1yf none_chosen) by(bdm_cutoff_bi) scheme(s1mono)   ytitle("Posterior Belief - Prior Belief", height (5)) xtitle("Information Value - Prior Belief", height (5))  note("          Slope{subscript:MWP < $2.5} =  `b_b' (`s_b')" "          Slope{subscript:MWP {&ge} $2.5} =  `b_a' (`s_a')" "          P-value =  `p'", justification(left) position(4) ring(0) size(medsmall)  )  legend(label(1 "MWP < $2.5 (N=`n_b')") label(2 "MWP {&ge} $2.5 (N=`n_a')") region(color(none)) cols(1) position(11) ring(0) size(medsmall)) xlabel(-.03 "-3%" -0.02 "-2%" -0.01 "-1%" 0 "0%" 0.01 "1%" 0.02 "2%" 0.03 "3%" 0.04 "4%" 0.05 "5%") ylabel( -0.01 "-1%" 0 "0%" 0.01 "1%" 0.02 "2%" )
graph export "output/learningrate_bdm_cutoff.eps", replace
graph export "output/learningrate_bdm_cutoff.pdf", replace
*Panel d( By Reward size)
reg w_revision_change_1yf gap_change_shown i.dummies_bdm_cutoff  prior_change_1yf gap_change_potential none_chosen if consistent_bdm==1 & high_reward==0, robust //low reward
local b_b=string(_b[gap_change_shown], "%9.3f")
local s_b=string(_se[gap_change_shown], "%9.3f")
local n_b=string(e(N), "%9.0fc")
reg w_revision_change_1yf gap_change_shown i.dummies_bdm_cutoff  prior_change_1yf gap_change_potential none_chosen if consistent_bdm==1 & high_reward==1, robust //high reward
local b_a=string(_b[gap_change_shown], "%9.3f")
local s_a=string(_se[gap_change_shown], "%9.3f")
local n_a=string(e(N), "%9.0fc")
reg w_revision_change_1yf gap_change_shown i.dummies_bdm_cutoff  prior_change_1yf gap_change_potential none_chosen if consistent_bdm==1 & high_reward==0 //low reward
est store est1
reg w_revision_change_1yf gap_change_shown i.dummies_bdm_cutoff  prior_change_1yf gap_change_potential none_chosen if consistent_bdm==1 & high_reward==1 //high reward
est store est2
quietly suest est1 est2, vce(robust)
test [est1_mean]gap_change_shown = [est2_mean]gap_change_shown
local p: display %4.3f `r(p)'
est clear
binscatter w_revision_change_1yf gap_change_shown if consistent_bdm==1,  color(gs2 gs7)  controls(i.dummies_bdm_cutoff gap_change_potential prior_change_1yf none_chosen) by(high_reward) scheme(s1mono)   ytitle("Posterior Belief - Prior Belief", height (5)) xtitle("Information Value - Prior Belief", height (5))  note("          Slope{subscript:Low} =  `b_b' (`s_b')" "          Slope{subscript:High} =  `b_a' (`s_a')" "          P-value =  `p'", justification(left) position(4) ring(0) size(medsmall)  )  legend(label(1 "Low Reward (N=`n_b')") label(2 "High Reward (N=`n_a')") region(color(none)) cols(1) position(11) ring(0) size(medsmall)) xlabel(-.03 "-3%" -0.02 "-2%" -0.01 "-1%" 0 "0%" 0.01 "1%" 0.02 "2%" 0.03 "3%" 0.04 "4%" 0.05 "5%") ylabel( -0.01 "-1%" 0 "0%" 0.01 "1%" 0.02 "2%" 0.03 "3%")
graph export "output/learningrate_reward.eps", replace
graph export "output/learningrate_reward.pdf", replace
*Panel e (By Uncertainty in Priors)
centile uncert_prior_change_1yf, c(50)
local median=`r(c_1)'
gen uncert_prior_change_1yf_bi=.
replace uncert_prior_change_1yf_bi=1 if  uncert_prior_change_1yf<`median' //Below
replace uncert_prior_change_1yf_bi=2 if  uncert_prior_change_1yf>=`median' //Above
reg w_revision_change_1yf gap_change_shown i.dummies_bdm_cutoff  prior_change_1yf gap_change_potential none_chosen if consistent_bdm==1 & uncert_prior_change_1yf_bi==1, robust //Below
local b_b=string(_b[gap_change_shown], "%9.3f")
local s_b=string(_se[gap_change_shown], "%9.3f")
local n_b=string(e(N), "%9.0fc")
reg w_revision_change_1yf gap_change_shown i.dummies_bdm_cutoff  prior_change_1yf gap_change_potential none_chosen if consistent_bdm==1 & uncert_prior_change_1yf_bi==2, robust //Above
local b_a=string(_b[gap_change_shown], "%9.3f")
local s_a=string(_se[gap_change_shown], "%9.3f")
local n_a=string(e(N), "%9.0fc")
reg w_revision_change_1yf gap_change_shown i.dummies_bdm_cutoff  prior_change_1yf gap_change_potential none_chosen if consistent_bdm==1 & uncert_prior_change_1yf_bi==1 //Below
est store est1
reg w_revision_change_1yf gap_change_shown i.dummies_bdm_cutoff  prior_change_1yf gap_change_potential none_chosen if consistent_bdm==1 & uncert_prior_change_1yf_bi==2 //Above
est store est2
quietly suest est1 est2, vce(robust)
test [est1_mean]gap_change_shown = [est2_mean]gap_change_shown
local p: display %4.3f `r(p)'
est clear
binscatter w_revision_change_1yf gap_change_shown if consistent_bdm==1, color(gs2 gs7)  controls(i.dummies_bdm_cutoff prior_change_1yf gap_change_potential none_chosen) by(uncert_prior_change_1yf_bi) scheme(s1mono)   ytitle("Posterior Belief - Prior Belief", height (5)) xtitle("Information Value - Prior Belief", height (5))  note("          Slope{subscript:Below} =  `b_b' (`s_b')" "          Slope{subscript:Above} =  `b_a' (`s_a')" "          P-value =  `p'", justification(left) position(4) ring(0) size(medsmall)  )  legend(label(1 "Below-median uncertainty (N=`n_b')") label(2 "Above-median uncertainty (N=`n_a')") region(color(none)) cols(1) position(11) ring(0) size(medsmall)) xlabel(-.03 "-3%" -0.02 "-2%" -0.01 "-1%" 0 "0%" 0.01 "1%" 0.02 "2%" 0.03 "3%" 0.04 "4%" 0.05 "5%") ylabel( -0.01 "-1%" 0 "0%" 0.01 "1%" 0.02 "2%" 0.03 "3%") 
graph export "output/learningrate_conf_prior_value.eps", replace
graph export "output/learningrate_conf_prior_value.pdf", replace
*Panel b (By Num)*
reg w_revision_change_1yf gap_change_shown i.dummies_bdm_cutoff gap_change_potential  prior_change_1yf none_chosen if numeracy_bi==0, robust
local b1=string(_b[gap_change_shown], "%9.3f")
local s1=string(_se[gap_change_shown], "%9.3f")
local n1=string(e(N), "%9.0fc")
reg w_revision_change_1yf gap_change_shown i.dummies_bdm_cutoff gap_change_potential  prior_change_1yf none_chosen if numeracy_bi==1, robust
local b2=string(_b[gap_change_shown], "%9.3f")
local s2=string(_se[gap_change_shown], "%9.3f")
local n2=string(e(N), "%9.0fc")
reg w_revision_change_1yf gap_change_shown i.dummies_bdm_cutoff gap_change_potential  prior_change_1yf none_chosen if numeracy_bi==0
est store est1
reg w_revision_change_1yf gap_change_shown i.dummies_bdm_cutoff gap_change_potential  prior_change_1yf none_chosen if numeracy_bi==1
est store est2
quietly suest est1 est2, vce(robust)
test [est1_mean]gap_change_shown = [est2_mean]gap_change_shown
local p: display %4.3f `r(p)'
est clear
binscatter w_revision_change_1yf gap_change_shown if consistent_bdm==1, color(gs2 gs7)  controls(i.dummies_bdm_cutoff gap_change_potential prior_change_1yf none_chosen) by(numeracy_bi) scheme(s1mono)   ytitle("Posterior Belief - Prior Belief", height (5)) xtitle("Information Value - Prior Belief", height (5)) note("          Slope{subscript:Low-Num} =  `b1' (`s1')" "          Slope{subscript:High-Num} =  `b2' (`s2')" "          P-value = `p'", justification(left) position(4) ring(0) size(medsmall)  )  legend(label(1 "Low Numeracy (N=`n1')") label(2 "High Numeracy (N=`n2')") region(color(none)) cols(1) position(11) ring(0) size(medsmall))  xlabel(-.03 "-3%" -0.02 "-2%" -0.01 "-1%" 0 "0%" 0.01 "1%" 0.02 "2%" 0.03 "3%" 0.04 "4%" 0.05 "5%")  ylabel( -0.02 "-2%" -0.01 "-1%" 0 "0%" 0.01 "1%" 0.02 "2%" 0.03 "3%") yscale(range(-0.02(0.005)0.035))
graph export "output/learningrate_bynum.eps", replace
graph export "output/learningrate_bynum.pdf", replace
***
*************************************************************************



**************************************************************************
*** Figure 4: Distribution of Prior and Posterior Beliefs: Individuals Who Were Shown Information vs. Individuals Who Were Not
use Data/data_ready_for_analysis, clear  
*Panel a (Information not to be Shown)*
count if cens_post_change_1yf!=. & dummy_shown==0 & info_chosen==1
local obs1=string(`r(N)', "%9.0g")
two hist cens_prior_change_1yf if info_chosen==1 & dummy_shown==0, lstyle(none) legend(off) title("Information Chosen: Forecast") percent start(-0.015) width(0.01) xlabel( -0.01 "{&le} -1%" 0 "0%" 0.01 "1%" 0.02 "2%" 0.03 "3%" 0.04 "4%" 0.05 "5%" 0.06 "6%" 0.07 "7%" 0.08 "{&ge} 8%") ylabel(0(20)60, grid) scheme(s1mono) xtitle("") ytitle("") name(forecast, replace) note("N=`obs1'", justification(right) position(2) ring(0)) || hist cens_post_change_1yf if info_chosen==1 & dummy_shown==0, percent start(-0.015) width(0.01) lcolor(black) fcolor(none)
count if cens_post_change_1yf!=. & dummy_shown==0 & info_chosen==2
local obs2=string(`r(N)', "%9.0g")
two hist cens_prior_change_1yf if info_chosen==2 & dummy_shown==0, lstyle(none) legend(off) title("Information Chosen: Last 1-Year Change") percent start(-0.015) width(0.01) xlabel( -0.01 "{&le} -1%" 0 "0%" 0.01 "1%" 0.02 "2%" 0.03 "3%" 0.04 "4%" 0.05 "5%" 0.06 "6%" 0.07 "7%" 0.08 "{&ge} 8%") ylabel(0(20)60, grid) scheme(s1mono) xtitle("") ytitle("") name(last1y, replace) note("N=`obs2'", justification(right) position(2) ring(0)) || hist cens_post_change_1yf if info_chosen==2 & dummy_shown==0, percent start(-0.015) width(0.01) lcolor(black) fcolor(none)
count if cens_post_change_1yf!=. & dummy_shown==0 & info_chosen==3
local obs3=string(`r(N)', "%9.0g")
two hist cens_prior_change_1yf if info_chosen==3 & dummy_shown==0, lstyle(none) legend(off) title("Information Chosen: Last 10-Year Change") percent start(-0.015) width(0.01) xlabel( -0.01 "{&le} -1%" 0 "0%" 0.01 "1%" 0.02 "2%" 0.03 "3%" 0.04 "4%" 0.05 "5%" 0.06 "6%" 0.07 "7%" 0.08 "{&ge} 8%") ylabel(0(20)60, grid) scheme(s1mono) xtitle("") ytitle("") name(last10y, replace) note("N=`obs3'", justification(right) position(2) ring(0)) || hist cens_post_change_1yf if info_chosen==3 & dummy_shown==0, percent start(-0.015) width(0.01) lcolor(black) fcolor(none)
count if cens_post_change_1yf!=. & dummy_shown==0 & info_chosen!=4
local obs4=string(`r(N)', "%9.0g")
two hist cens_prior_change_1yf if info_chosen!=4 & dummy_shown==0, lstyle(none) legend(off) title("Total")percent start(-0.015) width(0.01) xlabel( -0.01 "{&le} -1%" 0 "0%" 0.01 "1%" 0.02 "2%" 0.03 "3%" 0.04 "4%" 0.05 "5%" 0.06 "6%" 0.07 "7%" 0.08 "{&ge} 8%") ylabel(0(20)60, grid) scheme(s1mono) xtitle("") ytitle("") name(total, replace) note("N=`obs4'", justification(right) position(2) ring(0)) || hist cens_post_change_1yf if info_chosen!=4 & dummy_shown==0, percent start(-0.015) width(0.01) lcolor(black) fcolor(none)
graph combine forecast last1y last10y total, xcommon ycommon col(1) l1(Percent) graphregion(color(white)) b1("Expected Price Change") iscale(.7273) ysize(8)   graphregion(margin(zero))
graph export "output/postbelief_change_shown_0.eps", replace
graph export "output/postbelief_change_shown_0.pdf", replace
*Panel b (Information to be Shown)*
count if cens_post_change_1yf!=. & dummy_shown==1 & info_chosen==1
local obs1=string(`r(N)', "%9.0g")
two hist cens_prior_change_1yf if info_chosen==1 & dummy_shown==1, lstyle(none)  legend(off) title("Information Chosen: Forecast") percent start(-0.015) width(0.01) xlabel( -0.01 "{&le} -1%" 0 "0%" 0.01 "1%" 0.02 "2%" 0.03 "3%" 0.04 "4%" 0.05 "5%" 0.06 "6%" 0.07 "7%" 0.08 "{&ge} 8%") ylabel(0(20)60, grid) scheme(s1mono) xtitle("") ytitle("") name(forecast, replace) note("N=`obs1'", justification(right) position(2) ring(0)) || hist cens_post_change_1yf if info_chosen==1 & dummy_shown==1, percent start(-0.015) width(0.01) lcolor(black) fcolor(none)
count if cens_post_change_1yf!=. & dummy_shown==1 & info_chosen==2
local obs2=string(`r(N)', "%9.0g")
two hist cens_prior_change_1yf if info_chosen==2 & dummy_shown==1, lstyle(none) legend(off) title("Information Chosen: Last 1-Year Change") percent start(-0.015) width(0.01) xlabel( -0.01 "{&le} -1%" 0 "0%" 0.01 "1%" 0.02 "2%" 0.03 "3%" 0.04 "4%" 0.05 "5%" 0.06 "6%" 0.07 "7%" 0.08 "{&ge} 8%") ylabel(0(20)60, grid) scheme(s1mono) xtitle("") ytitle("") name(last1y, replace) note("N=`obs2'", justification(right) position(2) ring(0)) || hist cens_post_change_1yf if info_chosen==2 & dummy_shown==1, percent start(-0.015) width(0.01) lcolor(black) fcolor(none)
count if cens_post_change_1yf!=. & dummy_shown==1 & info_chosen==3
local obs3=string(`r(N)', "%9.0g")
two hist cens_prior_change_1yf if info_chosen==3 & dummy_shown==1, lstyle(none) legend(off) title("Information Chosen: Last 10-Year Change") percent start(-0.015) width(0.01) xlabel( -0.01 "{&le} -1%" 0 "0%" 0.01 "1%" 0.02 "2%" 0.03 "3%" 0.04 "4%" 0.05 "5%" 0.06 "6%" 0.07 "7%" 0.08 "{&ge} 8%") ylabel(0(20)60, grid) scheme(s1mono) xtitle("") ytitle("") name(last10y, replace) note("N=`obs3'", justification(right) position(2) ring(0)) || hist cens_post_change_1yf if info_chosen==3 & dummy_shown==1, percent start(-0.015) width(0.01) lcolor(black) fcolor(none)
count if cens_post_change_1yf!=. & dummy_shown==1 & info_chosen!=4
local obs4=string(`r(N)', "%9.0g")
two hist cens_prior_change_1yf if info_chosen!=4 & dummy_shown==1, lstyle(none) legend(off) title("Total")percent start(-0.015) width(0.01) xlabel( -0.01 "{&le} -1%" 0 "0%" 0.01 "1%" 0.02 "2%" 0.03 "3%" 0.04 "4%" 0.05 "5%" 0.06 "6%" 0.07 "7%" 0.08 "{&ge} 8%") ylabel(0(20)60, grid) scheme(s1mono) xtitle("") ytitle("") name(total, replace) note("N=`obs4'", justification(right) position(2) ring(0)) || hist cens_post_change_1yf if info_chosen!=4 & dummy_shown==0, percent start(-0.015) width(0.01) lcolor(black) fcolor(none)
graph combine forecast last1y last10y total, xcommon ycommon col(1) l1(Percent) graphregion(color(white)) b1("Expected Price Change") iscale(.7273) ysize(8)   graphregion(margin(zero))
graph export "output/postbelief_change_shown_1.eps", replace
graph export "output/postbelief_change_shown_1.pdf", replace
***
*************************************************************************


****************************** 
****** TABLES IN BODY ********
******************************

*************************************************************************
*** Table 1: Factors Associated with Information Choice
use Data/data_ready_for_analysis, clear
gen forcast_or_1yr=0
replace forcast_or_1yr=1 if info_chosen==1 | info_chosen==2

* Define programs
do "Code/Define appendmodels.do"

label var bdm_int1 "WTP" 
label var forecast_chosen "Forecast"
label var y1_chosen "1-yr"
label var y10_chosen "10-yrs"
label var forcast_or_1yr "Forcast or 1yr."
label var coll_grad "College graduate (0/1)"
label var HH_income "Income $>$    60,000"
label var age "Age"
label var female "Female (0/1)"
label var married "Married (0/1)"
label var white "White (0/1)"
label var total_numeracy "Numeracy (0-5)"

label var forecast_chosen "Forcast"
label var y1_chosen "1yr"
label var y10_chosen "10yr"
label var forcast_or_1yr "Forcast or 1yr"
label var forecast_chosen "WTP"
label var high_reward "High Reward"

sum uncert_prior_change_1yf
replace uncert_prior_change_1yf=(uncert_prior_change_1yf-`r(mean)')/`r(sd)'

eststo clear
qui: eststo b1: reg forecast_chosen HH_income, robust
qui: eststo b2: reg forecast_chosen coll_grad, robust
qui: eststo b3: reg forecast_chosen age, robust
qui: eststo b4: reg forecast_chosen female, robust
qui: eststo b5: reg forecast_chosen married, robust
qui: eststo b6: reg forecast_chosen white, robust
qui: eststo b7: reg forecast_chosen total_numeracy, robust
qui: eststo b8: reg forecast_chosen uncert_prior_change_1yf, robust
qui: eststo b9: reg forecast_chosen std_zillow_median, robust 
qui: eststo b10: reg forecast_chosen std_zillow_volatility_2y, robust 
qui: eststo b11: reg forecast_chosen looked_for_info, robust 
qui: eststo b12: reg forecast_chosen owner, robust 
qui: eststo b13: reg forecast_chosen qa0b_1, robust 
qui: eststo b14: reg forecast_chosen prob_move_and_buy , robust
qui: eststo b15: reg forecast_chosen info_looked_during, robust 
qui: eststo b16: reg forecast_chosen high_reward, robust 
eststo hours2: appendmodels b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 b16
qui: eststo b1: reg y1_chosen HH_income, robust
qui: eststo b2: reg y1_chosen coll_grad, robust
qui: eststo b3: reg y1_chosen age, robust
qui: eststo b4: reg y1_chosen female, robust
qui: eststo b5: reg y1_chosen married, robust
qui: eststo b6: reg y1_chosen white, robust
qui: eststo b7: reg y1_chosen total_numeracy, robust
qui: eststo b8: reg y1_chosen uncert_prior_change_1yf, robust
qui: eststo b9: reg y1_chosen std_zillow_median, robust 
qui: eststo b10: reg y1_chosen std_zillow_volatility_2y, robust 
qui: eststo b11: reg y1_chosen looked_for_info, robust 
qui: eststo b12: reg y1_chosen owner, robust 
qui: eststo b13: reg y1_chosen qa0b_1, robust 
qui: eststo b14: reg y1_chosen prob_move_and_buy, robust 
qui: eststo b15: reg y1_chosen info_looked_during, robust 
qui: eststo b16: reg y1_chosen high_reward, robust 
eststo hours3: appendmodels b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 b16
qui: eststo b1: reg y10_chosen HH_income, robust
qui: eststo b2: reg y10_chosen coll_grad, robust
qui: eststo b3: reg y10_chosen age, robust
qui: eststo b4: reg y10_chosen female, robust
qui: eststo b5: reg y10_chosen married, robust
qui: eststo b6: reg y10_chosen white, robust
qui: eststo b7: reg y10_chosen total_numeracy, robust
qui: eststo b8: reg y10_chosen uncert_prior_change_1yf, robust
qui: eststo b9: reg y10_chosen std_zillow_median, robust 
qui: eststo b10: reg y10_chosen std_zillow_volatility_2y, robust 
qui: eststo b11: reg y10_chosen looked_for_info, robust 
qui: eststo b12: reg y10_chosen owner, robust 
qui: eststo b13: reg y10_chosen qa0b_1, robust 
qui: eststo b14: reg y10_chosen prob_move_and_buy, robust 
qui: eststo b15: reg y10_chosen info_looked_during, robust  
qui: eststo b16: reg y10_chosen high_reward, robust 
eststo hours4: appendmodels b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 b16
qui: eststo b1: reg none_chosen HH_income, robust
qui: eststo b2: reg none_chosen coll_grad, robust
qui: eststo b3: reg none_chosen age, robust
qui: eststo b4: reg none_chosen female, robust
qui: eststo b5: reg none_chosen married, robust
qui: eststo b6: reg none_chosen white, robust
qui: eststo b7: reg none_chosen total_numeracy, robust
qui: eststo b8: reg none_chosen uncert_prior_change_1yf, robust
qui: eststo b9: reg none_chosen std_zillow_median, robust 
qui: eststo b10: reg none_chosen std_zillow_volatility_2y, robust 
qui: eststo b11: reg none_chosen looked_for_info, robust 
qui: eststo b12: reg none_chosen owner, robust 
qui: eststo b13: reg none_chosen qa0b_1, robust 
qui: eststo b14: reg none_chosen prob_move_and_buy, robust 
qui: eststo b15: reg none_chosen info_looked_during, robust 
qui: eststo b16: reg none_chosen high_reward, robust 
eststo hours6: appendmodels b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 b16
qui: eststo b1: reg forcast_or_1yr HH_income, robust
qui: eststo b2: reg forcast_or_1yr coll_grad, robust
qui: eststo b3: reg forcast_or_1yr age, robust
qui: eststo b4: reg forcast_or_1yr female, robust
qui: eststo b5: reg forcast_or_1yr married, robust
qui: eststo b6: reg forcast_or_1yr white, robust
qui: eststo b7: reg forcast_or_1yr total_numeracy, robust
qui: eststo b8: reg forcast_or_1yr uncert_prior_change_1yf, robust
qui: eststo b9: reg forcast_or_1yr std_zillow_median, robust 
qui: eststo b10: reg forcast_or_1yr std_zillow_volatility_2y, robust 
qui: eststo b11: reg forcast_or_1yr looked_for_info, robust 
qui: eststo b12: reg forcast_or_1yr owner, robust 
qui: eststo b13: reg forcast_or_1yr qa0b_1, robust 
qui: eststo b14: reg forcast_or_1yr prob_move_and_buy, robust 
qui: eststo b15: reg forcast_or_1yr info_looked_during, robust 
qui: eststo b16: reg forcast_or_1yr high_reward, robust 
eststo hours7: appendmodels b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 b16
eststo drop b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 b16

esttab using "output/MWP_determinants_2.tex", b(%9.3f) keep(HH_income coll_grad age female married white total_numeracy uncert_prior_change_1yf std_zillow_median std_zillow_volatility_2y looked_for_info owner qa0b_1 prob_move_and_buy high_reward info_looked_during) order(high_reward HH_income coll_grad age female married white total_numeracy uncert_prior_change_1yf std_zillow_median std_zillow_volatility_2y looked_for_info owner qa0b_1  prob_move_and_buy info_looked_during) varlabels(HH_income "Income $>$    60,000 (0/1)" coll_grad "College Graduate (0/1)" age "Age"  female "Female (0/1)" married "Married (0/1)" white "White (0/1)"  education_bi "College (0/1)" total_numeracy "Numeracy (0-5)" uncert_prior_change_1yf "Uncertainty in Prior Belief (Std)" std_zillow_median "Median House Value in State (Std)" std_zillow_volatility_2y "House Value Volatility in State (Std)" looked_for_info "Looked for Info in Past (0/1)" owner "Homeowner (0/1)" qa0b_1 "Conf. in Past Recall (1-5)" prob_move_and_buy "Prob Move and Buy Home in 3 Years" high_reward "High Reward (0/1)" info_looked_during "Look at Info During Survey (0/1)") se label nonotes replace booktabs  mlabel("Choose Forcast" "Choose 1yr" "Choose 10yr" "Choose None" "Choose Forcast or 1yr" ) gap compress star(* 0.10 ** 0.05 *** 0.01) 

filefilter "output/MWP_determinants_2.tex" "output/MWP_determinants_3.tex", replace from("main") to ("")
erase "output/MWP_determinants_2.tex"

file open myfile7 using "output/MWP_determinants_3.tex", read
forvalues i=1(1)45{
file read myfile7 line`i'
}
reg forecast_chosen
local forecast=string(_b[_cons], "%9.2f")
local n_for=e(N)
reg y1_chosen
local y1=string(_b[_cons], "%9.2f")
local n_y1=e(N)
reg y10_chosen
local y10=string(_b[_cons], "%9.2f")
local n_y10=e(N)
reg forcast_or_1yr
local for_y1=string(_b[_cons], "%9.2f")
local n_for_y1=e(N)
reg none_chosen
local none=string(_b[_cons], "%9.2f")
local n_none=e(N)

cap: file close table 
file open table using "output/MWP_determinants.tex", write replace
file write table "\resizebox{1.0\textwidth}{!}{%" _n
forvalues i=1(1)4 {
file write table "`line`i''" _n
}
file write table "&\multicolumn{5}{c}{Indicator: chose...} \\ \cmidrule(lr){2-6}" _n
file write table "  & Forecast & 1yr & 10yr & None & Forecast or 1yr           \\"_n
file write table "`line5'" _n
forvalues i=7(1)40 {
file write table "`line`i''" _n
}
file write table "Mean& `forecast' & `y1'& `y10'& `none' &`for_y1'  \\"_n
file write table "Observations & `n_for' & `n_y1' & `n_y10' & `n_none' & `n_for_y1' \\"_n
file write table "\bottomrule"_n
forvalues i=43(1)45 {
file write table "`line`i''" _n
}
file write table "}"_n
file close table
file close myfile7
erase "output/MWP_determinants_3.tex"
*** 
*************************************************************************


*************************************************************************
*** Table 2: Factors Associated with WTP and Response Times
use Data/data_ready_for_analysis, clear
gen log_qtime_qa4_con=log_qtime_qa4 if dummy_shown==1
* Define programs
do "Code/Define appendmodels.do"
egen z2conf_past = std(qa0b_1)
label var bdm_int1 "WTP" 
label var coll_grad "College graduate (0/1)"
label var HH_income "Income $>$    60,000"
label var age "Age"
label var female "Female (0/1)"
label var married "Married (0/1)"
label var white "White (0/1)"
label var total_numeracy "Numeracy (0-5)"
label var high_reward "High Reward"
sum uncert_prior_change_1yf
replace uncert_prior_change_1yf=(uncert_prior_change_1yf-`r(mean)')/`r(sd)'
eststo clear
qui: eststo b1: intreg bdm_int1 bdm_int2 HH_income, robust
qui: eststo b2: intreg bdm_int1 bdm_int2 coll_grad, robust
qui: eststo b3: intreg bdm_int1 bdm_int2 age, robust
qui: eststo b4: intreg bdm_int1 bdm_int2 female, robust
qui: eststo b5: intreg bdm_int1 bdm_int2 married, robust
qui: eststo b6: intreg bdm_int1 bdm_int2 white, robust
qui: eststo b7: intreg bdm_int1 bdm_int2 total_numeracy, robust
qui: eststo b8: intreg bdm_int1 bdm_int2 uncert_prior_change_1yf, robust
qui: eststo b9: intreg bdm_int1 bdm_int2 std_zillow_median, robust 
qui: eststo b10: intreg bdm_int1 bdm_int2 std_zillow_volatility_2y, robust 
qui: eststo b11: intreg bdm_int1 bdm_int2 looked_for_info, robust 
qui: eststo b12: intreg bdm_int1 bdm_int2 owner, robust 
qui: eststo b13: intreg bdm_int1 bdm_int2 qa0b_1, robust 
qui: eststo b14: intreg bdm_int1 bdm_int2 prob_move_and_buy, robust 
qui: eststo b15: intreg bdm_int1 bdm_int2 info_looked_during, robust 
qui: eststo b16: intreg bdm_int1 bdm_int2 high_reward , robust 
eststo hours3: appendmodels b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 b16
qui: eststo b1: reg log_qtime_qa4 HH_income, robust
qui: eststo b2: reg log_qtime_qa4 coll_grad, robust
qui: eststo b3: reg log_qtime_qa4 age, robust
qui: eststo b4: reg log_qtime_qa4 female, robust
qui: eststo b5: reg log_qtime_qa4 married, robust
qui: eststo b6: reg log_qtime_qa4 white, robust
qui: eststo b7: reg log_qtime_qa4 total_numeracy, robust
qui: eststo b8: reg log_qtime_qa4 uncert_prior_change_1yf, robust
qui: eststo b9: reg log_qtime_qa4 std_zillow_median, robust 
qui: eststo b10: reg log_qtime_qa4 std_zillow_volatility_2y, robust 
qui: eststo b11: reg log_qtime_qa4 looked_for_info, robust 
qui: eststo b12: reg log_qtime_qa4 owner, robust 
qui: eststo b13: reg log_qtime_qa4 qa0b_1, robust 
qui: eststo b14: reg log_qtime_qa4 prob_move_and_buy, robust 
qui: eststo b15: reg log_qtime_qa4 bdm_cutoff, robust 
qui: eststo b16: reg log_qtime_qa4 info_looked_during, robust  
qui: eststo b17: reg log_qtime_qa4 high_reward , robust 
eststo hours2: appendmodels b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 b16 b17
qui: eststo b1: reg log_qtime_qa4_con HH_income, robust
qui: eststo b2: reg log_qtime_qa4_con coll_grad, robust
qui: eststo b3: reg log_qtime_qa4_con age, robust
qui: eststo b4: reg log_qtime_qa4_con female, robust
qui: eststo b5: reg log_qtime_qa4_con married, robust
qui: eststo b6: reg log_qtime_qa4_con white, robust
qui: eststo b7: reg log_qtime_qa4_con total_numeracy, robust
qui: eststo b8: reg log_qtime_qa4_con uncert_prior_change_1yf, robust
qui: eststo b9: reg log_qtime_qa4_con std_zillow_median, robust 
qui: eststo b10: reg log_qtime_qa4_con std_zillow_volatility_2y, robust 
qui: eststo b11: reg log_qtime_qa4_con looked_for_info, robust 
qui: eststo b12: reg log_qtime_qa4_con owner, robust 
qui: eststo b13: reg log_qtime_qa4_con qa0b_1, robust 
qui: eststo b14: reg log_qtime_qa4_con prob_move_and_buy, robust
qui: eststo b15: reg log_qtime_qa4_con bdm_cutoff, robust 
qui: eststo b16: reg log_qtime_qa4_con info_looked_during, robust  
qui: eststo b17: reg log_qtime_qa4_con high_reward , robust 
eststo hours1: appendmodels b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 b16 b17 
eststo drop b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 b16 b17
esttab using "output/table4new_2.tex", b(%9.3f) keep(HH_income coll_grad age female married white total_numeracy uncert_prior_change_1yf std_zillow_median std_zillow_volatility_2y looked_for_info owner qa0b_1 prob_move_and_buy high_reward info_looked_during bdm_cutoff) order( high_reward HH_income coll_grad age female married white total_numeracy uncert_prior_change_1yf std_zillow_median std_zillow_volatility_2y looked_for_info owner qa0b_1  prob_move_and_buy  info_looked_during bdm_cutoff) varlabels(HH_income "Income $>$    60,000 (0/1)" coll_grad "College Graduate (0/1)" age "Age"  female "Female (0/1)" married "Married (0/1)" white "White (0/1)"  education_bi "College (0/1)" total_numeracy "Numeracy (0-5)" uncert_prior_change_1yf "Uncertainty in Prior Belief (Std)" std_zillow_median "Median House Value in State (Std)" std_zillow_volatility_2y "House Value Volatility in State (Std)" looked_for_info "Looked for Info in Past (0/1)" owner "Homeowner (0/1)" qa0b_1 "Conf. in Past Recall (1-5)" prob_move_and_buy "Prob Move and Buy Home in 3 Years" high_reward "High Reward (0/1)" info_looked_during "Look at Info During Survey (0/1)" bdm_cutoff "WTP") se label nonotes replace booktabs  mlabel( "WTP" "Log Min Posterior Belief" "Log Min Posterior Belief $|$ See Info") gap compress star(* 0.10 ** 0.05 *** 0.01) 
filefilter "output/table4new_2.tex" "output/table4new_3.tex", replace from("main") to ("")
erase "output/table4new_2.tex"
file open myfile7 using "output/table4new_3.tex", read
forvalues i=1(1)47{
file read myfile7 line`i'
}
intreg bdm_int1 bdm_int2
local mwp=string(_b[_cons], "%9.2f")
local n_mwp=e(N)
reg log_qtime_qa4
local q4=string(_b[_cons], "%9.2f")
local n_q4=e(N)
reg log_qtime_qa4_con
local q4_con=string(_b[_cons], "%9.2f")
local n_q4_con=e(N)
cap: file close table 
file open table using "output/table4new.tex", write replace
file write table "\resizebox{0.75\textwidth}{!}{%" _n
forvalues i=1(1)4 {
file write table "`line`i''" _n
}
file write table " & \multicolumn{1}{p{2cm}}{\centering Willingness To Pay } & \multicolumn{1}{p{2cm}}{\centering  Log Min Posterior Belief } &  \multicolumn{1}{p{2cm}}{\centering  Log Min Posterior Belief $|$ See Info }           \\"_n
file write table "`line5'" _n
file write table "`line7'" _n
forvalues i=9(1)43 {
file write table "`line`i''" _n
}
file write table "Mean & `mwp'  & `q4' & `q4_con' \\"_n
file write table "Observations & `n_mwp' & `n_q4' & `n_q4_con'   \\"_n
file write table "\bottomrule"_n
forvalues i=46(1)47 {
file write table "`line`i''" _n
}
file write table "}"_n
file close table
file close myfile7
erase "output/table4new_3.tex"
*** 
*************************************************************************



*************************************************************************
*** Table 3: Cost of Information and Dispersion of Expectations
use Data/data_ready_for_analysis, clear 
gen high_price=wrow>4 if wrow!=.

keep if info_chosen!=4 & consistent_bdm==1
local cols 5
local header "\begin{tabular}{l l  c c c} \hline\hline"
local footer "\end{tabular}"
cap: file close table
file open table using "output/evolution_table_price.tex", write replace
file write table "`header'" _n
file write table "&&\textbf{Low Price}&\textbf{High Price}&P-value Diff\\" _n
file write table "&&(1)&(2)&(3)\\\addlinespace"_n
label var prior_change_1yf  "Prior Belief"
label var post_change_1yf  "Posterior Belief"
label var follow_up_change_1yf  "Posterior Belief follow-up"
replace post_change_1yf = 100 * post_change_1yf
replace prior_change_1yf = 100 * prior_change_1yf
replace follow_up_change_1yf= 100* follow_up_change_1yf
replace uncert_post_change_1yf=100*uncert_post_change_1yf
replace uncert_prior_change_1yf=100*uncert_prior_change_1yf
replace follow_up_uncert_change_1yf=100*follow_up_uncert_change_1yf

foreach var in prior_change_1yf post_change_1yf {
sum `var' if high_price==0
gen abs_`var'=abs(`var'-`r(mean)') if high_price==0
sum `var' if high_price==1
replace abs_`var'=abs(`var'-`r(mean)') if high_price==1
}

*******PRIOR*******
*Prior-Low Price 
reg prior_change_1yf if high_price==0, robust
local b_prior_low=string(_b[_cons], "%9.2f")
local se_prior_low=string(_se[_cons], "%9.3f")
ttest prior_change_1yf, by(high_price)
local p_mean= string(`r(p)',"%9.2f")

reg abs_prior_change_1yf if high_price==0, robust
local b_abs_prior_low=string(_b[_cons], "%9.2f")
local se_abs_prior_low=string(_se[_cons], "%9.3f")
ttest abs_prior_change_1yf, by(high_price)
local p_abs_mean= string(`r(p)',"%9.2f")

sum prior_change_1yf if high_price==0
local sd_prior_low=string(`r(sd)',"%9.2f")
local se_sd_prior_low=string((`r(sd)'/sqrt(2*(`r(N)'-2))), "%9.3f")
local n_prior_low=string(`r(N)',"%9.2f")

sum uncert_prior_change_1yf if high_price==0
local conf_prior_low=string(`r(mean)',"%9.2f")
local se_conf_prior_low=string((`r(sd)'/sqrt(2*(`r(N)'-2))), "%9.3f")
ttest uncert_prior_change_1yf, by(high_price)
local p_conf = string(`r(p)',"%9.2f")

*Prior-High Price
reg prior_change_1yf if high_price==1, robust
local b_prior_high=string(_b[_cons], "%9.2f")
local se_prior_high=string(_se[_cons], "%9.3f")

reg abs_prior_change_1yf if high_price==1, robust
local b_abs_prior_high=string(_b[_cons], "%9.2f")
local se_abs_prior_high=string(_se[_cons], "%9.3f")

sum prior_change_1yf if high_price==1
local sd_prior_high=string(`r(sd)',"%9.2f")
local se_sd_prior_high=string((`r(sd)'/sqrt(2*(`r(N)'-2))), "%9.3f")
local n_prior_high=string(`r(N)',"%9.2f")

sum uncert_prior_change_1yf if high_price==1
local conf_prior_high=string(`r(mean)',"%9.2f")
local se_conf_prior_high=string((`r(sd)'/sqrt(2*(`r(N)'-2))), "%9.3f")

local t_sd=(`sd_prior_low'-`sd_prior_high')/sqrt((((`se_sd_prior_low')^2))+(((`se_sd_prior_high')^2)))
local p_sd_prior= string((1-normal(abs(`t_sd')))*2, "%9.2f")

*** Share Acquiring info 
sum dummy_shown if high_price==0
local lp_infoshown=string(100*`r(mean)',"%9.2f")
local se_lp_infoshown=string((100*`r(sd)'/sqrt(2*(`r(N)'-2))), "%9.3f")

sum dummy_shown if high_price==1
local hp_infoshown=string(100*`r(mean)',"%9.2f")
local se_hp_infoshown=string((100*`r(sd)'/sqrt(2*(`r(N)'-2))), "%9.3f")

ttest dummy_shown, by(high_price)
local p_shown = string(`r(p)',"%9.2f")

file write table "\multicolumn{2}{c}{Obtained Signal (\%)}& `lp_infoshown' (`se_lp_infoshown') & `hp_infoshown' (`se_hp_infoshown') & `p_shown'\\\addlinespace"_n
file write table "Expectations:	&&&&\\\addlinespace"_n
file write table "Prior& Mean & `b_prior_low' (`se_prior_low')  & `b_prior_high' (`se_prior_high') & `p_mean'\\" _n
file write table "& MAD & `b_abs_prior_low' (`se_abs_prior_low') & `b_abs_prior_high' (`se_abs_prior_high')  & `p_abs_mean'\\" _n
*file write table "& S.D. & `sd_prior_low' (`se_sd_prior_low') & `sd_prior_high' (`se_sd_prior_high')  & `p_sd_prior'\\" _n
file write table "& Uncertainty & `conf_prior_low' (`se_conf_prior_low')  & `conf_prior_high' (`se_conf_prior_high')  & `p_conf'\\" _n

* disagreement
preserve
	keep 	userid p*_change_1yf uncert_p*_change_1yf high_price // the p* stands for prior and post
	renvars userid p*_change_1yf uncert_p*_change_1yf , postfix(_i)
	save change_i.tmp, replace
	renvars userid* p*_change_1yf* uncert_p*_change_1yf* , subst(_i _j)
	joinby high_price using change_i.tmp // all pairwise matchings within info / noinfo groups
	drop if userid_j==userid_i // without meetings with oneself
	egen double userid_min = rowmin(userid*)
	keep if userid_i == userid_min // and dropping duplicates
	local z = 1.96
	local u = "prior" 
	foreach x in i j {
		gen `u'_min_`x' = `u'_change_1yf_`x' - `z' * uncert_`u'_change_1yf_`x'
		gen `u'_max_`x' = `u'_change_1yf_`x' + `z' * uncert_`u'_change_1yf_`x'
	}

	g `u'_disagree  = ( `u'_change_1yf_i < `u'_change_1yf_j & `u'_max_i < `u'_min_j ) ///
						| ( `u'_change_1yf_i > `u'_change_1yf_j & `u'_min_i > `u'_max_j )
	replace `u'_disagree  = . if `u'_change_1yf_i==. | `u'_change_1yf_j ==.
	replace `u'_disagree = 100*`u'_disagree
	
	ivreg2 `u'_disagree if high_price==0, clu(userid_i userid_j)
	local b_`u'_d_low	=string(_b[_cons], "%9.2f")
	local se_`u'_d_low	=string(_se[_cons], "%9.2f")	

	ivreg2 `u'_disagree if high_price==1, clu(userid_i userid_j)
	local b_`u'_d_high	=string(_b[_cons], "%9.2f")
	local se_`u'_d_high	=string(_se[_cons], "%9.2f")	

	ivreg2 `u'_disagree high_price, clu(userid_i userid_j) small
	local t = _b[high_price]/_se[high_price]
	local p_d = string(2*ttail(e(df_r),abs(`t')), "%9.2f")

	file write table "& Disagreement (\%) & `b_prior_d_low' (`se_prior_d_low')  & `b_prior_d_high' (`se_prior_d_high')  & `p_d'\\\addlinespace" _n
restore

*******POSTERIOR*******
*Posterior-Low Price
reg post_change_1yf if high_price==0 , robust
local b_posterior_low=string(_b[_cons], "%9.2f")
local se_posterior_low=string(_se[_cons], "%9.3f")
local n1=string(e(N), "%9.0fc")
ttest post_change_1yf, by(high_price)
local p_mean= string(`r(p)',"%9.2f")

reg abs_post_change_1yf if high_price==0, robust
local b_abs_posterior_low=string(_b[_cons], "%9.2f")
local se_abs_posterior_low=string(_se[_cons], "%9.3f")
ttest abs_post_change_1yf, by(high_price)
local p_abs_mean= string(`r(p)',"%9.2f")

sum post_change_1yf if high_price==0
local sd_posterior_low=string(`r(sd)',"%9.2f")
local se_sd_posterior_low=string((`r(sd)'/sqrt(2*(`r(N)'-2))), "%9.3f")
local n_post_low=string(`r(N)',"%9.2f")

sum uncert_post_change_1yf if high_price==0 
local conf_post_low=string(`r(mean)',"%9.2f")
local se_conf_post_low=string((`r(sd)'/sqrt(2*(`r(N)'-2))), "%9.3f")
ttest uncert_post_change_1yf , by(high_price)
local p_conf = string(`r(p)',"%9.2f")

*Posterior-High Price
reg post_change_1yf if high_price==1, robust
local b_posterior_high=string(_b[_cons], "%9.2f")
local se_posterior_high=string(_se[_cons], "%9.3f")

reg abs_post_change_1yf if high_price==1, robust
local b_abs_posterior_high=string(_b[_cons], "%9.2f")
local se_abs_posterior_high=string(_se[_cons], "%9.3f")

sum post_change_1yf if high_price==1
local sd_posterior_high=string(`r(sd)',"%9.2f")
local se_sd_posterior_high=string((`r(sd)'/sqrt(2*(`r(N)'-2))), "%9.3f")
local n_post_high=string(`r(N)',"%9.2f")

sum uncert_post_change_1yf if high_price==1
local conf_post_high=string(`r(mean)',"%9.2f")
local se_conf_post_high=string((`r(sd)'/sqrt(2*(`r(N)'-2))), "%9.3f")

local t_sd=(`sd_posterior_low'-`sd_posterior_high')/sqrt((((`se_sd_posterior_low')^2))+(((`se_sd_posterior_high')^2)))
local p_sd_post= string((1-normal(abs(`t_sd')))*2, "%9.2f")
display `p_sd_post'

file write table "Posterior& Mean & `b_posterior_low' (`se_posterior_low')  & `b_posterior_high' (`se_posterior_high') & `p_mean'\\" _n
file write table "& MAD & `b_abs_posterior_low' (`se_abs_posterior_low') & `b_abs_posterior_high' (`se_abs_posterior_high')  & `p_abs_mean'\\" _n
*file write table "& SD & `sd_posterior_low' (`se_sd_posterior_low') & `sd_posterior_high' (`se_sd_posterior_high')  &  `p_sd_post'\\" _n
file write table "& Uncertainty & `conf_post_low' (`se_conf_post_low')  & `conf_post_high' (`se_conf_post_high')  & `p_conf'\\" _n

preserve
	keep 	userid p*_change_1yf uncert_p*_change_1yf high_price // the p* stands for prior and post
	renvars userid p*_change_1yf uncert_p*_change_1yf , postfix(_i)
	save change_i.tmp, replace
	renvars userid* p*_change_1yf* uncert_p*_change_1yf* , subst(_i _j)
	joinby high_price using change_i.tmp // all pairwise matchings within info / noinfo groups
	drop if userid_j==userid_i // without meetings with oneself
	egen double userid_min = rowmin(userid*)
	keep if userid_i == userid_min // and dropping duplicates
	local z = 1.96
	local u = "post" 
	foreach x in i j {
		gen `u'_min_`x' = `u'_change_1yf_`x' - `z' * uncert_`u'_change_1yf_`x'
		gen `u'_max_`x' = `u'_change_1yf_`x' + `z' * uncert_`u'_change_1yf_`x'
	}

	g `u'_disagree  = ( `u'_change_1yf_i < `u'_change_1yf_j & `u'_max_i < `u'_min_j ) ///
						| ( `u'_change_1yf_i > `u'_change_1yf_j & `u'_min_i > `u'_max_j )
	replace `u'_disagree  = . if `u'_change_1yf_i==. | `u'_change_1yf_j ==.
	replace `u'_disagree = 100*`u'_disagree						
	ivreg2 `u'_disagree if high_price==0, clu(userid_i userid_j)
	local b_`u'_d_low	=string(_b[_cons], "%9.2f")
	local se_`u'_d_low	=string(_se[_cons], "%9.2f")	
	ivreg2 `u'_disagree if high_price==1, clu(userid_i userid_j)
	local b_`u'_d_high	=string(_b[_cons], "%9.2f")
	local se_`u'_d_high	=string(_se[_cons], "%9.2f")	
	ivreg2 `u'_disagree high_price, clu(userid_i userid_j) small
	local t = _b[high_price]/_se[high_price]
	local p_d = string(2*ttail(e(df_r),abs(`t')), "%9.2f")
	file write table "& Disagreement (\%)		 & `b_post_d_low' (`se_post_d_low')  & `b_post_d_high' (`se_post_d_high')  & `p_d'\\\midrule" _n
restore
count if high_price==0
local m0=`r(N)'
display `m0'
count if high_price==1
local m1=`r(N)'
file write table " \multicolumn{2}{c}{Observations}& `m0' & `m1' &\\\midrule"_n
file write table "`footer'"
file close table
***
*************************************************************************


*************************************************************************
*** Table 4: Effect of Information-Acquisition on the Distribution of Expectations
use Data/data_ready_for_analysis, clear  
local cols 7
local header "\begin{tabular}{l l c c } \hline\hline"
local footer "\end{tabular}"
cap: file close table
file open table using "output/disp_expect_table_AF.tex", write replace
file write table "`header'" _n
*file write table "&&\multicolumn{2}{c}{\textbf{Baseline Sample}}\\\cmidrule(lr){3-4}" _n
file write table "& & Prior & Posterior  \\\cmidrule(lr){3-4}" _n
file write table "&&(1)&(2)\\" _n

local cuts num ba inc own age_hi
label var prior_change_1yf  "Prior Belief"
label var post_change_1yf  "Posterior Belief"
label var follow_up_change_1yf  "Posterior Belief follow-up"
replace post_change_1yf = 100 * post_change_1yf
replace prior_change_1yf = 100 * prior_change_1yf
replace follow_up_change_1yf= 100* follow_up_change_1yf
gen confidence_prior=100*uncert_prior_change_1yf
gen confidence_post=100*uncert_post_change_1yf
gen confidence_fo=100*follow_up_uncert_change_1yf

capt prog drop runmodel
program runmodel, eclass
	*Prior*
	foreach var in prior_change_1yf post_change_1yf follow_up_change_1yf {
	sum `var'
	gen abs_`var'=abs(`var'-`r(mean)')
	}
	reg prior_change_1yf, robust
	local b_prior=string(_b[_cons], "%9.2f")
	local se_prior=string(_se[_cons], "%9.3f")
	reg abs_prior_change_1yf, robust
	local b_abs_prior=string(_b[_cons], "%9.2f")
	local se_abs_prior=string(_se[_cons], "%9.3f")
	
	sum prior_change_1yf
	local sd_prior=string(`r(sd)',"%9.2f")
	local se_sd_prior=string((`r(sd)'/sqrt(2*(`r(N)'-2))), "%9.3f")
	sum confidence_prior
	local conf_prior=string(`r(mean)',"%9.2f")
	local se_conf_prior=string((`r(sd)'/sqrt(2*(`r(N)'-2))), "%9.3f")
	*Baseline*
	reg post_change_1yf
	local b_posterior=string(_b[_cons], "%9.2f")
	local se_posterior=string(_se[_cons], "%9.3f")
	reg abs_post_change_1yf, robust
	local b_abs_post=string(_b[_cons], "%9.2f")
	local se_abs_post=string(_se[_cons], "%9.3f")
	
	local n1=string(e(N), "%9.0fc")
	sum post_change_1yf
	local sd_posterior=string(`r(sd)',"%9.2f")
	local se_sd_posterior=string((`r(sd)'/sqrt(2*(`r(N)'-2))), "%9.3f")
	sum confidence_post
	local conf_post=string(`r(mean)',"%9.2f")
	local se_conf_post=string((`r(sd)'/sqrt(2*(`r(N)'-2))), "%9.3f")
	
	*Follow-up
	reg follow_up_change_1yf, robust
	local b_fu=string(_b[_cons], "%9.2f")
	local se_fu=string(_se[_cons], "%9.3f")
	reg abs_follow_up_change_1yf, robust
	local b_abs_fu=string(_b[_cons], "%9.2f")
	local se_abs_fu=string(_se[_cons], "%9.3f")

	local n2=string(e(N), "%9.0fc")
	sum follow_up_change_1yf
	local sd_fu=string(`r(sd)',"%9.2f")
	local se_sd_fu=string((`r(sd)'/sqrt(2*(`r(N)'-2))), "%9.3f")
	sum confidence_fo
	local conf_fo=string(`r(mean)',"%9.2f")
	local se_conf_fo=string((`r(sd)'/sqrt(2*(`r(N)'-2))), "%9.3f")

	file write table "$group & Mean &  `b_prior' (`se_prior') & `b_posterior' (`se_posterior')  \\"_n
	file write table "N=`n1' & MAD & `b_abs_prior' (`se_abs_prior') & `b_abs_post' (`se_abs_post')  \\"_n
	file write table " & Uncertainty & `conf_prior' (`se_conf_prior') & `conf_post' (`se_conf_post') \\"_n
	
	// disagreement part:
	
	// rescaling for convenience
	replace post_change_1yf = 1/100 * post_change_1yf
	replace prior_change_1yf = 1/100 * prior_change_1yf
	replace follow_up_change_1yf= 1/100* follow_up_change_1yf
	// renaming for convenience
	rename follow_up_change_1yf pfollowup_change_1yf
	rename follow_up_uncert_change_1yf uncert_pfollowup_change_1yf
	
	keep 	userid p*_change_1yf uncert_p*_change_1yf // the p* stands for prior and post, and now also (p)followup
	renvars userid p*_change_1yf uncert_p*_change_1yf , postfix(_i)
	g aa=1
	save change_i.tmp, replace
	renvars userid* p*_change_1yf* uncert_p*_change_1yf* , subst(_i _j)
	joinby aa  using change_i.tmp // all pairwise matchings within info / noinfo groups
	drop if userid_j==userid_i // without meetings with oneself
	egen double userid_min = rowmin(userid*)
	keep if userid_i == userid_min // and dropping duplicates
	local z = 1.96
	foreach u in prior post pfollowup { 
	foreach x in i j {
		gen `u'_min_`x' = `u'_change_1yf_`x' - `z' * uncert_`u'_change_1yf_`x'
		gen `u'_max_`x' = `u'_change_1yf_`x' + `z' * uncert_`u'_change_1yf_`x'
	}

	g `u'_disagree  = ( `u'_change_1yf_i < `u'_change_1yf_j & `u'_max_i < `u'_min_j ) ///
						| ( `u'_change_1yf_i > `u'_change_1yf_j & `u'_min_i > `u'_max_j )
	replace `u'_disagree  = . if `u'_change_1yf_i==. | `u'_change_1yf_j ==.
	replace `u'_disagree = 100*`u'_disagree					

	ivreg2 `u'_disagree , clu(userid_i userid_j)
	local b_`u'_d	=string(_b[_cons], "%9.2f")
	local se_`u'_d	=string(_se[_cons], "%9.2f")	

	}

	file write table "& Disagreem. (\%)		 & `b_prior_d' (`se_prior_d')  & `b_post_d' (`se_post_d')  \\\addlinespace\midrule" _n
end
file write table "\multicolumn{2}{c}{\textbf{Information Shown}} && \\" _n
preserve
keep if dummy_shown==1
global group All
runmodel
restore
preserve
keep if dummy_shown==1 & info_chosen==1
global group Forecast
runmodel
restore
preserve
keep if dummy_shown==1 & info_chosen==2
global group "1 Year Change"
runmodel
restore
preserve
keep if dummy_shown==1 & info_chosen==3
global group "10 Year Change"
runmodel
restore
file write table "\multicolumn{2}{c}{\textbf{Information Not Shown}} && \\" _n
preserve
keep if dummy_shown==0
global group All
runmodel
restore
preserve
keep if dummy_shown==0 & info_chosen==1
global group Forecast
runmodel
restore
preserve
keep if dummy_shown==0 & info_chosen==2
global group "1 Year Change"
runmodel
restore
preserve
keep if dummy_shown==0 & info_chosen==3
global group "10 Year Change"
runmodel
restore

file write table "`footer'"
file close table
erase "change_i.tmp"
*** 
*************************************************************************



****************************** 
*** FIGURES IN APPENDIX A ****
******************************


*************************************************************************
*** Figure A.1: Prior Beliefs: Expectations about Median House Price
*Panel a (Point Estimate)*
use Data/data_ready_for_analysis, clear  
replace prior_value_1yf=190000 if prior_value_1yf<190000 & prior_value_1yf!=.
replace prior_value_1yf=210000  if prior_value_1yf>210000 & prior_value_1yf!=.
sum prior_value_1yf
local obs=string(`r(N)', "%9.0g")
hist prior_value_1yf, percent scheme(s1mono) start(190000) width(1000) xlabel(190000 "$190,000" 195000 "$195,000" 200000 "$200,000" 205000 "$205,000" 210000 "$210,000", angle(45)) xline(193800, lcolor(black) lpattern(dash))  xti("Expected Price in December 2017", height (5)) yti("Percent", height(5) )  title("") note("N=`obs'", justification(right) position(2) ring(0))
graph export "output/Prior_belief_value_histogram.eps", replace 
graph export "output/Prior_belief_value_histogram.pdf", replace 
*Panel b (Uncertainty)*
preserve
// AF: we need to replace missing values with 0 first, otherwise means will be too high (won't add up to zero):
foreach x in qa2_1 qa2_2 qa2_3 qa2_4 qa2_5 {
replace `x'=0 if `x'==.
}
collapse (mean) qa2_1 qa2_2 qa2_3 qa2_4 qa2_5
gen id=1
reshape long qa2_, i(id) j(group)
drop id
label define group 1 "X<90%" 2 "90%<X<99%" 3 "99%<X<101%" 4 "101%<X<110%" 5 "X>110%"
label values group group 
graph bar (mean) qa2_, ylabel(0(20)60) over(group, label(angle(45))) legend(off) scheme(s1mono) b1title("X: Point estimate made in Panel (a)", height (5))  yti("Percent", height(5) ) note("N=1119", justification(right) position(2) ring(0))
graph export "output/Prior_belief_uncertainty_histogram.eps", replace 
graph export "output/Prior_belief_uncertainty_histogram.pdf", replace 
list
restore
***
*************************************************************************


**************************************************************************
*** Figure A.2: Short- and Medium-Term Learning Rates from Information
use Data/data_ready_for_analysis, clear
*Panel a (Short Term)*
reg w_revision_change_1yf gap_change_shown i.dummies_bdm_cutoff gap_change_potential  prior_change_1yf none_chosen if consistent_bdm==1, robust // consistent_bdm==1 not required here, dummies_bdm_cutoff missing if inconsistent bdm
local b=string(_b[gap_change_shown], "%9.3f")
local s=string(_se[gap_change_shown], "%9.3f")
local r2=string(e(r2), "%9.3f")
local n=string(e(N), "%9.0fc")
binscatter w_revision_change_1yf gap_change_shown if consistent_bdm==1, color(black) name(test, replace) controls(i.dummies_bdm_cutoff gap_change_potential  prior_change_1yf none_chosen) scheme(s1mono) ytitle("Posterior Belief - Prior Belief", height (5)) xtitle("Information Value - Prior Belief", height (5)) note("          Slope=  `b' (`s')" "          R{superscript:2} =  `r2'" "          N =  `n'", justification(left) position(4) ring(0) size(medsmall)  )  xlabel(-.03 "-3%" -0.02 "-2%" -0.01 "-1%" 0 "0%" 0.01 "1%" 0.02 "2%" 0.03 "3%" 0.04 "4%" 0.05 "5%")  ylabel( -0.005 "-0.5%" 0 "0.0%" 0.005 "0.5%" 0.01 "1.0%" 0.015 "1.5%" 0.02 "2.0%"  0.025 "2.5%") yscale(range(-0.005(0.0005)0.025))
graph export "output/learningrate_shortterm.eps", replace
graph export "output/learningrate_shortterm.pdf", replace
*Panel b (Medium-Term)
reg w_f_up_revision_change_1yf gap_change_shown i.dummies_bdm_cutoff gap_change_potential prior_change_1yf none_chosen if consistent_bdm==1, robust
local b=string(_b[gap_change_shown], "%9.3f")
local s=string(_se[gap_change_shown], "%9.3f")
local r2=string(e(r2), "%9.3f")
local n=string(e(N), "%9.0fc")
binscatter w_f_up_revision_change_1yf gap_change_shown if consistent_bdm==1, color(black) controls(i.dummies_bdm_cutoff gap_change_potential prior_change_1yf none_chosen ) scheme(s1mono) ytitle("Follow-up Belief - Prior Belief", height (5)) xtitle("Information Value - Prior Belief", height (5)) note("          Slope=  `b' (`s')" "          R{superscript:2} =  `r2'" "          N =  `n'", justification(left) position(4) ring(0) size(medsmall)  )  xlabel(-.03 "-3%" -0.02 "-2%" -0.01 "-1%" 0 "0%" 0.01 "1%" 0.02 "2%" 0.03 "3%" 0.04 "4%" 0.05 "5%")  ylabel( -0.005 "-0.5%" 0 "0.0%" 0.005 "0.5%" 0.01 "1.0%" 0.015 "1.5%" 0.02 "2.0%"  0.025 "2.5%") yscale(range(-0.005(0.0005)0.025))
graph export "output/learningrate_mediumterm.eps", replace
graph export "output/learningrate_mediumterm.pdf", replace
***
*************************************************************************


**************************************************************************
*** Figure A.3: Changes from Prior to Posterior Beliefs
use Data/data_ready_for_analysis, clear  
keep if none_chosen==0
*Panel a (Revisions if Signal Shown)*
reg w_revision_change_1yf gap_change_potential i.dummies_bdm_cutoff if dummy_shown==1, robust
local b=string(_b[gap_change_potential], "%9.3f")
local s=string(_se[gap_change_potential], "%9.3f")
local r2=string(e(r2), "%9.3f")
local n=string(e(N), "%9.0fc")
binscatter w_revision_change_1yf gap_change_potential if dummy_shown==1, color(black) controls(i.dummies_bdm_cutoff) scheme(s1mono) ytitle("Posterior Belief - Prior Belief", height (5)) xtitle("Information Value - Prior Belief", height (5)) note("          Slope=  `b' (`s')" "          R{superscript:2} =  `r2'" "          N =  `n'", justification(left) position(4) ring(0) size(medsmall)  )  xlabel( -0.08 "-8%"  -0.06 "-6%"  -0.04 "-4%"  -0.02 "-2%"  0 "0%"  0.02 "2%"  0.04 "4%"  0.06 "6%"  0.08 "8%" ) ylabel( -0.04 "-4%" -0.03 "-3%" -0.02 "-2%" -0.01 "-1%" 0 "0%" 0.01 "1%" 0.02 "2%" 0.03 "3%" 0.04 "4%" 0.05 "5%")
graph export "output/learning_if_signal_shown.eps", replace
graph export "output/learning_if_signal_shown.pdf", replace

*Panel b (Revisions if Signal not Shown)*
reg w_revision_change_1yf gap_change_potential i.dummies_bdm_cutoff if dummy_shown==0, robust
local b=string(_b[gap_change_potential], "%9.3f")
local s=string(_se[gap_change_potential], "%9.3f")
local r2=string(e(r2), "%9.3f")
local n=string(e(N), "%9.0fc")
binscatter w_revision_change_1yf gap_change_potential if dummy_shown==0, color(black) controls(i.dummies_bdm_cutoff) scheme(s1mono) ytitle("Posterior Belief - Prior Belief", height (5)) xtitle("Information Value - Prior Belief", height (5)) note("          Slope=  `b' (`s')" "          R{superscript:2} =  `r2'" "          N =  `n'", justification(left) position(4) ring(0) size(medsmall)  ) xlabel( -0.08 "-8%"  -0.06 "-6%"  -0.04 "-4%"  -0.02 "-2%"  0 "0%"  0.02 "2%"  0.04 "4%"  0.06 "6%"  0.08 "8%" ) ylabel( -0.04 "-4%" -0.03 "-3%" -0.02 "-2%" -0.01 "-1%" 0 "0%" 0.01 "1%" 0.02 "2%" 0.03 "3%" 0.04 "4%" 0.05 "5%") 
graph export "output/learning_if_signal_notshown.eps", replace
graph export "output/learning_if_signal_notshown.pdf", replace
***
*************************************************************************





****************************** 
**** TABLES IN APPENDIX A ****
******************************


*************************************************************************
*** Table A.1: Descriptive Statistics and Randomization Balance by Reward Size
set more off
use Data/data_ready_for_analysis, clear 
gen high_price=wrow>4 if wrow!=.
replace high_price=high_price+1
gen nrtr=1 if high_reward==0
replace nrtr=2 if high_reward==1

label var prior_value_1yf_1000 "Prior Belief (1,000s)"
label var prior_change_1yf "Prior Belief (\% change)"
label var HH_income "Income $>$ 60,000 (0/1)"
label var coll_grad "College Graduate (0/1)"
label var age "Age"
label var female "Female (0/1)"
label var married "Married (0/1)"
label var white "White (0/1)"
label var own_residency "Homeowner (0/1)"
label var foll_resp "Resp. Follow-Up Survey (0/1)"

label var total_numeracy "Numeracy (0-5)" 
label var uncert_prior_change_1yf "Uncertainty in Prior Belief (Normalized)" 
label var zillow_median_1000s "Median House Value in State (1,000s)" 
label var zillow_volatility_2y_norm "House Value Volatility in State (Normalized)"
label var looked_for_info "Looked for Info in Past (0/1)"
label var qa0b_1 "Conf. in Past Recall (1-5)"
label var prob_move "Probability Move in 3yr."
label var prob_move_and_buy "Probability Move and Buy in 3yr"

label var info_looked_during "Look at Info During Survey (0/1)"

file open table using "output/randomization_balance_reward_size.tex", write replace
file write table "\resizebox{0.9\textwidth}{!}{%" _n
file write table "\begin{tabular}{lccccccc} \hline" _n
file write table " & & & &F-Test & & &F-Test\\"_n
file write table " & All & Low Reward & High Reward & P-value & Low Price & High Price & P-value\\"_n
file write table " & (1) & (2) & (3) & (4) & (5) & (6) & (7)\\\hline"_n

foreach var in  prior_value_1yf_1000 prior_change_1yf HH_income coll_grad age female married white own_residency total_numeracy uncert_prior_change_1yf zillow_median_1000s zillow_volatility_2y_norm looked_for_info qa0b_1 prob_move_and_buy foll_resp{
	if `var'==prior_value_1yf_1000 {
		local format %9.1f
	}
	else if `var'==age {
		local format %9.2f
	}
	else {
		local format %9.3f
	}
	
	sum `var'
	local m0=string(r(mean), "`format'")
	local s0=string(r(sd), "%9.3f")

	forvalues i=1/2 {
		sum `var' if nrtr==`i'
		local m1_`i': display `format' `r(mean)'
		local s1_`i': display %9.3f `r(sd)'
	}
	
	reg `var' i.nrtr, robust
	local p_1: display %5.3f Ftail(e(df_m),e(df_r),e(F))

	forvalues i=1/2 {
		sum `var' if high_price==`i'
		local m2_`i': display `format' `r(mean)'
		local s2_`i': display %9.3f `r(sd)'
	}

	reg `var' i.high_price, robust
	local p_2: display %9.3f Ftail(e(df_m),e(df_r),e(F))
	
	local var_label: variable label `var'	
	
	file write table " `var_label'  & `m0'  & `m1_1' & `m1_2' & `p_1' & `m2_1' & `m2_2' & `p_2' \\"_n
	file write table  " & (`s0') & (`s1_1') & (`s1_2')  &  & (`s2_1') & (`s2_2') &  \\"_n
	file write table  " &  &  &  &  &  &  &  \\"_n
	}
cou if !missing(prior_value_1yf_1000)
local m0=string(r(N), "%9.0fc")
forvalues i=1/2 {
	cou if nrtr==`i'
	local m1_`i'=string(r(N), "%9.0fc")
	}
forvalues i=1/2 {
	cou if high_price==`i'
	local m2_`i'=string(r(N), "%9.0fc")
	}
	file write table "\hline"_n
	file write table  " Observations & `m0' & `m1_1' & `m1_2' &  & `m2_1' & `m2_2' &  \\"_n
file write table "\bottomrule \end{tabular}" _n
file write table "}" _n
file close table
***
************************************************************************


*************************************************************************
*** Table A.2: Descriptive Statistics by Follow-Up Invitation and Response
set more off
use Data/data_ready_for_analysis, clear 

label var prior_value_1yf_1000 "Prior Belief (1,000s)"
label var prior_change_1yf "Prior Belief (\% change)"
label var HH_income "Income $>$ 60,000 (0/1)"
label var coll_grad "College Graduate (0/1)"
label var age "Age"
label var female "Female (0/1)"
label var married "Married (0/1)"
label var white "White (0/1)"
label var own_residency "Homeowner (0/1)"
label var foll_resp "Responded to Follow-Up Survey"

label var total_numeracy "Numeracy (0-5)" 
label var uncert_prior_change_1yf "Uncertainty in Prior Belief (Normalized)" 
label var zillow_median_1000s "Median House Value in State (1,000s)" 
label var zillow_volatility_2y_norm "House Value Volatility in State (Normalized)"
label var looked_for_info "Looked for Info in Past (0/1)"
label var qa0b_1 "Conf. in Past Recall (1-5)"
label var prob_move "Probability Move in 3yr."
label var prob_move_and_buy "Probability Move and Buy in 3yr"
label var high_reward "High Reward (0/1)"
label var inform1 "Informedness 1yr. (Std)."
label var inform10 "Informedness 10yr. (Std)."
label var info_looked_during "Look at Info During Survey (0/1)"

file open table using "output/randomization_balance_followup_invit.tex", write replace
file write table "\resizebox{0.9\textwidth}{!}{%" _n
file write table "\begin{tabular}{lccccccc} \hline" _n
file write table "&& \multicolumn{3}{c}{Invited to Follow-Up}&\multicolumn{3}{c}{Responded Follow-Up invitation}\\\cmidrule(lr){3-5}\cmidrule(lr){6-8}"_n
file write table " &&&& F-test & & &F-test\\"_n
file write table " & All & No & Yes &  P-value & No & Yes & P-value\\"_n
file write table " & (1) & (2) & (3) & (4) & (5) & (6) & (7)\\\hline"_n
foreach var in prior_value_1yf_1000 prior_change_1yf HH_income coll_grad age female married white own_residency total_numeracy uncert_prior_change_1yf zillow_median_1000s zillow_volatility_2y_norm looked_for_info qa0b_1 prob_move_and_buy high_reward {
	if `var'==prior_value_1yf_1000 {
		local format %9.1f
	}
	else if `var'==age {
		local format %9.2f
	}
	else {
		local format %9.3f
	}
	
	sum `var'
	local m0=string(r(mean), "`format'")
	local s0=string(r(sd), "%9.3f")
	local var_label: variable label `var'
	
		sum `var' if invite_flag==0
		local m1=string(r(mean), "`format'")
		local s1=string(r(sd), "%9.3f")
		sum `var' if invite_flag==1
		local m2=string(r(mean), "`format'")
		local s2=string(r(sd), "%9.3f")
		reg `var' invite_flag, robust
		local p1=string(Ftail(e(df_m),e(df_r),e(F)), "%9.3f")
		
		
		sum `var' if foll_resp2==0
		local m3=string(r(mean), "`format'")
		local s3=string(r(sd), "%9.3f")
		sum `var' if foll_resp2==1
		local m4=string(r(mean), "`format'")
		local s4=string(r(sd), "%9.3f")
		reg `var' foll_resp2, robust
		local p2=string(Ftail(e(df_m),e(df_r),e(F)), "%9.3f")
		
	
		local var_label: variable label `var'	
	
	file write table " `var_label' & `m0' & `m1' & `m2' & `p1' & `m3' & `m4' & `p2' \\"_n
	file write table  " & (`s0') & (`s1') & (`s2') &  & (`s3') & (`s4') &  \\"_n
	
	file write table " &  &  &  &  &  &  \\"_n
	}
cou if !missing(prior_value_1yf_1000)
local m0=string(r(N), "%9.0fc")
cou if invite_flag==0
local m1=string(r(N), "%9.0fc")
cou if invite_flag==1
local m2=string(r(N), "%9.0fc")
cou if foll_resp2==0
local m3=string(r(N), "%9.0fc")
cou if foll_resp2==1
local m4=string(r(N), "%9.0fc") 
	file write table "\hline"_n
file write table "Observations & `m0' & `m1' & `m2' &  & `m3' & `m4' & \\"_n
file write table "\bottomrule \end{tabular}" _n
file write table "}" _n
file close table
*** 
*************************************************************************



*************************************************************************
*** Table A.3: Factors Associated with Information Choice – Multivariate Results
use Data/data_ready_for_analysis, clear  
gen forcast_or_1yr=0
replace forcast_or_1yr=1 if info_chosen==1 | info_chosen==2

* Define programs
do "Code/Define appendmodels.do"

egen z2conf_past = std(qa0b_1)
label var bdm_int1 "WTP" 
label var forecast_chosen "Forecast"
label var y1_chosen "1-yr"
label var y10_chosen "10-yrs"
label var none_chosen "None"
label var forcast_or_1yr "Forecast or 1yr"
label var coll_grad "College graduate (0/1)"
label var HH_income "Income $>$ 60,000"
label var age "Age"
label var female "Female (0/1)"
label var married "Married (0/1)"
label var white "White (0/1)"
label var high_reward "High Reward"

sum uncert_prior_change_1yf
replace uncert_prior_change_1yf=(uncert_prior_change_1yf-`r(mean)')/`r(sd)'
*fix missing values
cap drop fix_*
cap drop miss_*
foreach var in coll_grad HH_income age married white female total_numeracy looked_for_info owner prob_move_and_buy uncert_prior_change_1yf std_zillow_median std_zillow_volatility_2y qa0b_1 high_reward{
	gen fix_`var'=`var'
	replace fix_`var'=0 if missing(`var')
	gen miss_`var'=missing(`var')
}

eststo clear
qui: eststo: reg forecast_chosen fix_* miss_*, robust 
qui: eststo: reg y1_chosen fix_* miss_*, robust 
qui: eststo: reg y10_chosen fix_* miss_*, robus 
qui: eststo: reg none_chosen fix_* miss_*, robust 
qui: eststo: reg forcast_or_1yr fix_* miss_*, robus 

esttab using "output/MWP_determinants_multivariate_2.tex", b(%9.3f) keep(fix_high_reward fix_HH_income fix_coll_grad fix_age fix_female fix_married fix_white fix_total_numeracy fix_uncert_prior_change_1yf ///
fix_std_zillow_median fix_std_zillow_volatility_2y fix_looked_for_info fix_owner fix_qa0b_1 fix_prob_move_and_buy ) order(fix_high_reward fix_HH_income fix_coll_grad fix_age fix_female fix_married ///
fix_white fix_total_numeracy fix_uncert_prior_change_1yf fix_std_zillow_median fix_std_zillow_volatility_2y fix_looked_for_info fix_owner fix_qa0b_1 fix_prob_move_and_buy)  ///
varlabels(fix_HH_income "Income $>$    60,000 (0/1)" fix_coll_grad "College Graduate (0/1)" fix_age "Age"  fix_female "Female (0/1)" fix_married "Married (0/1)" fix_white "White (0/1)"  fix_education_bi "College (0/1)" ///
fix_total_numeracy "Numeracy (0-5)" fix_uncert_prior_change_1yf "Uncertainty in Prior Belief (Std)" fix_std_zillow_median "Median House Value in State (Std)" fix_std_zillow_volatility_2y "House Value Volatility in State (Std)" ///
fix_looked_for_info "Looked for Info in Past (0/1)" fix_owner "Homeowner (0/1)" fix_qa0b_1 "Conf. in Past Recall (1-5)" fix_prob_move_and_buy "Prob Move and Buy in 3 Years" fix_high_reward "High Reward (0/1)") ///
nomtitle se label nonotes replace booktabs  mlabels(, depvar) gap compress star(* 0.10 ** 0.05 *** 0.01) 

filefilter "output/MWP_determinants_multivariate_2.tex" "output/MWP_determinants_multivariate_3.tex", replace from("main") to ("")
erase "output/MWP_determinants_multivariate_2.tex"

file open myfile77 using "output/MWP_determinants_multivariate_3.tex", read
forvalues i=1(1)43{
file read myfile77 line`i'
}

quietly reg forecast_chosen
local forecast=string(_b[_cons], "%9.2f")
quietly reg forecast_chosen fix_* miss_*, robust 
local n_for=e(N)
local r2_for: display %3.2f e(r2)

quietly reg y1_chosen
local y1=string(_b[_cons], "%9.2f")
quietly reg y1_chosen fix_* miss_*, robust 
local n_y1=e(N)
local r2_y1: display %3.2f e(r2)

quietly reg y10_chosen
local y10=string(_b[_cons], "%9.2f")
quietly reg y10_chosen fix_* miss_*, robust 
local n_y10=e(N)
local r2_y10: display %3.2f e(r2)

quietly reg forcast_or_1yr
local y1_for=string(_b[_cons], "%9.2f")
quietly reg forcast_or_1yr fix_* miss_*, robust 
local n_y1_for=e(N)
local r2_y1_for: display %3.2f e(r2)

quietly reg none_chosen
local none=string(_b[_cons], "%9.2f")
quietly reg none_chosen fix_* miss_*, robust 
local n_none=e(N)
local r2_none: display %3.2f e(r2) 

cap: file close table 
file open table using "output/MWP_determinants_multivariate.tex", write replace
file write table "\resizebox{1.0\textwidth}{!}{%" _n
forvalues i=1(1)4 {
file write table "`line`i''" _n
}
file write table "&\multicolumn{5}{c}{Indicator: chose...} \\ \cmidrule(lr){2-6}" _n
file write table "   & Forecast&1yr& 10yr & None  & Forecast or 1yr                      \\"_n
file write table "`line5'" _n
forvalues i=7(1)38 {
file write table "`line`i''" _n
}
file write table "Mean& `forecast' & `y1'& `y10'& `none' &`y1_for'  \\"_n
file write table "Observations & `n_for' & `n_y1' & `n_y10'  & `n_none'  & `n_y1_for'  \\"_n
file write table "R2  & `r2_for' & `r2_y1' & `r2_y10' & `r2_none' & `r2_y1_for' \\"_n

file write table "\bottomrule"_n
forvalues i=41(1)43 {
file write table "`line`i''" _n
}
file write table "}"_n
file close table
file close myfile77
erase "output/MWP_determinants_multivariate_3.tex"
*** 
*************************************************************************


*************************************************************************
** Table A.4: Factors Associated with Willingness to Pay and Response Times - Multivariate Results
use Data/data_ready_for_analysis, clear  
* Define programs
do "Code/Define appendmodels.do"
egen z2conf_past = std(qa0b_1)
label var bdm_int1 "WTP" 
label var coll_grad "College graduate (0/1)"
label var HH_income "Income $>$ 60,000"
label var age "Age"
label var female "Female (0/1)"
label var married "Married (0/1)"
label var white "White (0/1)"
label var high_reward "High Reward"

gen log_qtime_qa4_con=log_qtime_qa4 if dummy_shown==1

sum uncert_prior_change_1yf
replace uncert_prior_change_1yf=(uncert_prior_change_1yf-`r(mean)')/`r(sd)'

*fix missing values
cap drop fix_*
cap drop miss_*
foreach var in high_reward coll_grad HH_income age married white female total_numeracy looked_for_info owner prob_move_and_buy uncert_prior_change_1yf std_zillow_median std_zillow_volatility_2y qa0b_1{
	gen fix_`var'=`var'
	replace fix_`var'=0 if missing(`var')
	gen miss_`var'=missing(`var')
}

*endogneous fixed vars
foreach var in info_looked_during none_chosen y1_chosen y10_chosen{
	gen endo_fix_`var'=`var'
	replace endo_fix_`var'=0 if missing(`var')
	gen endo_miss_`var'=missing(`var')
}

*drop info_10yr from cols 5 and 6
gen uncon_fix_none_chosen=endo_fix_none_chosen
gen uncon_miss_none_chosen=endo_miss_none_chosen
drop endo_fix_none_chosen endo_miss_none_chosen

*endogneous fixed vars: WTP (seperate to exclude from col 1/2
gen wtp_fix=bdm_cutoff
replace wtp_fix=0 if missing(bdm_cutoff)
gen wtp_miss=missing(bdm_cutoff)

eststo clear
qui: eststo: intreg bdm_int1 bdm_int2 fix_* miss_* , robust
qui: eststo: intreg bdm_int1 bdm_int2 fix_* miss_* endo_fix_* endo_miss_* uncon_miss* uncon_fix* , robust
qui: eststo: reg log_qtime_qa4 fix_* miss_*, robust
qui: eststo: reg log_qtime_qa4 fix_* miss_* endo_fix_* endo_miss_* wtp_fix wtp_miss uncon_miss* uncon_fix*, robust
qui: eststo: reg log_qtime_qa4_con fix_* miss_* , robust
qui: eststo: reg log_qtime_qa4_con fix_* miss_* endo_fix_* endo_miss_* wtp_fix wtp_miss, robust 

esttab using "output/table4new_multi_2.tex", b(%9.3f) keep(fix_HH_income fix_coll_grad fix_age fix_female fix_married fix_white fix_total_numeracy fix_uncert_prior_change_1yf ///
fix_std_zillow_median fix_std_zillow_volatility_2y fix_looked_for_info fix_owner fix_qa0b_1 fix_prob_move_and_buy fix_high_reward endo_fix_info_looked_during ///
 endo_fix_y1_chosen endo_fix_y10_chosen uncon_fix_none_chosen wtp_fix) order(fix_high_reward fix_HH_income fix_coll_grad fix_age fix_female fix_married fix_white fix_total_numeracy ///
fix_uncert_prior_change_1yf fix_std_zillow_median fix_std_zillow_volatility_2y fix_looked_for_info fix_owner fix_qa0b_1 fix_prob_move_and_buy  ///
endo_fix_info_looked_during endo_fix_y1_chosen endo_fix_y10_chosen uncon_fix_none_chosen wtp_fix) varlabels(fix_HH_income "Income $>$    60,000 (0/1)" fix_coll_grad "College Graduate (0/1)" ///
fix_age "Age"  fix_female "Female (0/1)" fix_married "Married (0/1)" fix_white "White (0/1)"  fix_education_bi "College (0/1)" fix_total_numeracy "Numeracy (0-5)" ///
fix_uncert_prior_change_1yf "Uncertainty in Prior Belief (Std)" fix_std_zillow_median "Median House Value in State (Std)" fix_std_zillow_volatility_2y "House Value Volatility in State (Std)" ///
fix_looked_for_info "Looked for Info in Past (0/1)" fix_owner "Homeowner (0/1)" fix_qa0b_1 "Conf. in Past Recall (1-5)" fix_prob_move_and_buy "Prob Move and Buy in 3 Years" ///
fix_high_reward "High Reward (0/1)" endo_fix_info_looked_during "Look at Info During Survey (0/1)"   ///
endo_fix_y1_chosen "Choose 1yr. (0/1)" endo_fix_y10_chosen "Choose 10yr. (0/1)" uncon_fix_none_chosen "Choose None (0/1)" wtp_fix "WTP") nomtitle se label nonotes replace booktabs  ///
mlabels(, depvar) gap compress star(* 0.10 ** 0.05 *** 0.01) 

filefilter "output/table4new_multi_2.tex" "output/table4new_multi_3.tex", replace from("main") to ("")
erase "output/table4new_multi_2.tex"

file open myfile77 using "output/table4new_multi_3.tex", read
forvalues i=1(1)53{
file read myfile77 line`i'
}

quietly intreg bdm_int1 bdm_int2
local wtp=string(_b[_cons], "%9.2f")
quietly intreg bdm_int1 bdm_int2 fix_* miss_*, robust 
local n_wtp=e(N)
local r2_wtp: display %3.2f e(r2)
quietly intreg bdm_int1 bdm_int2 fix_* miss_* endo_fix_* endo_miss_* uncon_miss* uncon_fix*, robust 
local endo_n_wtp=e(N)
local endo_r2_wtp: display %3.2f e(r2)

quietly reg log_qtime_qa4
local q4=string(_b[_cons], "%9.2f")
quietly reg log_qtime_qa4 fix_* miss_*, robust 
local n_q4=e(N)
local r2_q4: display %3.2f e(r2)
quietly reg log_qtime_qa4 fix_* miss_* endo_fix_* endo_miss_* wtp_fix wtp_miss uncon_miss* uncon_fix*, robust 
local endo_n_q4=e(N)
local endo_r2_q4: display %3.2f e(r2)

quietly reg log_qtime_qa4_con
local q4_con=string(_b[_cons], "%9.2f")
quietly reg log_qtime_qa4_con fix_* miss_*, robust 
local n_q4_con=e(N)
local r2_q4_con: display %3.2f e(r2)
quietly reg log_qtime_qa4_con fix_* miss_* endo_fix_* endo_miss_* wtp_fix wtp_miss, robust 
local endo_n_q4_con=e(N)
local endo_r2_q4_con: display %3.2f e(r2)

cap: file close table 
file open table using "output/table4new_multi.tex", write replace
file write table "\resizebox{0.95\textwidth}{!}{%" _n
forvalues i=1(1)4 {
file write table "`line`i''" _n
}
file write table " & \multicolumn{1}{p{2cm}}{\centering Willingness To Pay } & \multicolumn{1}{p{2cm}}{\centering Willingness To Pay }  & \multicolumn{1}{p{2cm}}{\centering  Log Min Posterior Belief } & \multicolumn{1}{p{2cm}}{\centering  Log Min Posterior Belief } & \multicolumn{1}{p{2cm}}{\centering  Log Min Posterior Belief $|$ See Info } & \multicolumn{1}{p{2cm}}{\centering  Log Min Posterior Belief $|$ See Info }  \\"_n
file write table "`line5'" _n
file write table "`line7'" _n
forvalues i=9(1)49 {
file write table "`line`i''" _n
}
file write table "Mean & `wtp' & `wtp'  & `q4' & `q4' & `q4_con'  & `q4_con' \\"_n
file write table "Observations & `n_wtp' & `endo_n_wtp' & `n_q4' & `endo_n_q4'  & `n_q4_con'  & `endo_n_q4_con' \\"_n
file write table "R2 & `r2_wtp' & `endo_r2_wtp' & `r2_q4' & `endo_r2_q4' & `r2_q4_con' & `endo_r2_q4_con' \\"_n
file write table "\bottomrule"_n
forvalues i=52(1)53 {
file write table "`line`i''" _n
}
file write table "}"_n
file close table
file close myfile77
erase "output/table4new_multi_3.tex"
*** 
*************************************************************************
